recursive permutation
function findPerms(str) {
if (str.length === 1) return [str]
let all = []
for (let i = 0; i < str.length; i++) {
const currentLetter = str[i]
const remainingLetters = str.slice(0,i) + str.slice(i+1)
const permsOfRemainingLetters = findPerms(remainingLetters)
permsOfRemainingLetters.forEach(
subPerm => {all.push(currentLetter + subPerm)}
)
}
return all
}
Also in JavaScript:
- enviando post angular 8
- reflection of an graph javascript
- react checkbox onChange
- switch (new date().getday())
- mobile number format (xxx) xxx-xxxx
- printing in a single line in javascript
- javascript create object key from variable
- json object check if key exists java
- eslint version check in react
- Javascript singly linked list
- javascript date to string
- get unique id angular
- js async await
- for of and for in javascript
- JavaScript append HTML
- escape in javascript
- sqrt javascript
- react history listen get previous location
- js match any number string
- UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
- javascript loop over classlist
- javascript to help find overflow elements
- js check if array
- JavaScript append text to div