Skip to content

Instantly share code, notes, and snippets.

@willshepp28
Created December 12, 2020 01:38
Show Gist options
  • Save willshepp28/bcefe24bee5f33b86ee761c76df650ff to your computer and use it in GitHub Desktop.
Save willshepp28/bcefe24bee5f33b86ee761c76df650ff to your computer and use it in GitHub Desktop.
var restoreString = function(s, indices) {
let shuffled = [];
for(let i = 0; i < s.length; i++) {
shuffled[indices[i]] = s[i];
}
return shuffled.join("");
};
restoreString("codeleet", [4,5,6,7,0,2,1,3])
restoreString("abc", [0,1,2])
restoreString("aiohn", [3,1,4,2,0])
restoreString("aaiougrt", [4,0,2,6,7,3,1,5])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment