Frage im Vorstellungsgespräch bei Wayfair

Write a code that show all possible permutation from a given String.

Antworten zu Vorstellungsgespräch

Anonym

7. März 2014

The answer is available on programmerinterview.com, relatively easy if you have learned the answer before going to interview. But quite difficult to find a solution on the spot.

Anonym

13. Mai 2019

function swap(arr, indA, indB){ const temp=arr[indA]; arr[indA]=arr[indB]; arr[indB]=temp; return arr; } function allPerms(str){ if (str.length===1) return str; const perm=[...str]; const perms=[]; for (let i=0; i0;j--){ perms.push([...swap(perm,j-1,j)].join('')); } } return perms; }

Anonym

13. Mai 2019

I solved it by myself. Took me an hour. Idk if this is the best solution though