Created
December 12, 2020 01:38
-
-
Save willshepp28/bcefe24bee5f33b86ee761c76df650ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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