W3cshool--permutation combination de-weight algorithm challenge

Source: Internet
Author: User
Tags array length

    functionPermalone (str) {if(Str.length = = 1)returnstr; varA = STR.SUBSTR (0, 1), one = [a], count = 0, toggle =true;  for(vari = 0; i< str.length-1; i++) {            vartemp = str[i+1];//Remove the letters that need to be insertedone =cha (one, temp)}//determine if the array has consecutive duplicates         for(vark = 0; k<one.length; k++) {//gets each item in the array             for(varL = 0; l<one[k].length-1; l++) {//string that iterates through each item                if(One[k][l] = = one[k][l+1]) {//If there are two consecutive letters equal to each other                    //decision variables to determine eligibilityToggle =false;  Break; } Else{Toggle=true; }            }            //determine if toggle is true            if(toggle) count++; }        returncount; } permalone (' Abfdefa '); /*interpolation algorithm str: the array to be inserted V: the letter to be inserted*/    functioncha (str, v) {varlen = str.length;//Get Array length        vararr = []//the last array to return         for(vari = 0; i<len; i++) {             for(varj = 0; j<str[i].length+1; J + +) {//the number of times you need to insert equals the string length plus one                varStar = str[i].substring (0, J)varEnd =str[i].substring (J, Str[i].length); varOK = star + V +end;            Arr.push (OK); }        }        returnarr; }

W3cshool--permutation combination de-weight algorithm challenge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.