Advertisement
stanevplamen

All combos 3, DFS, mine

Sep 20th, 2022
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.46 KB | Software | 0 0
  1. var str = "abcde";
  2. var length = str.length;
  3. var conterIndx = 0;
  4. var result = [];
  5.  
  6. debugger;
  7.  
  8. var processStr = function(str, idx) {
  9.     if(idx == str.length) {
  10.         return;
  11.     }
  12.     var char = str.charAt(idx);
  13.     var tempArr =  [char];
  14.     for(var res in result) {
  15.         tempArr.push("" + result[res] + char);
  16.     }
  17.     result = result.concat(tempArr);
  18.     idx++;
  19.     processStr(str, idx);
  20.     return result;
  21. }
  22.  
  23. var res = processStr(str, conterIndx);
  24. console.log(res);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement