Skip to content

Instantly share code, notes, and snippets.

@kingsamadesu
Created December 3, 2020 21:18
Show Gist options
  • Save kingsamadesu/d0fd91a1b2107d16e080edd50afee3b8 to your computer and use it in GitHub Desktop.
Save kingsamadesu/d0fd91a1b2107d16e080edd50afee3b8 to your computer and use it in GitHub Desktop.
1528. Shuffle String -with java- (leetcode.com)
/*
Your memory usage beats 94.03 % of java submissions.
Your runtime beats 99.93 % of java submissions.
*/
class Solution {
public String restoreString(String s, int[] indices) {
int count = 0;
char[] array = new char[indices.length];
for(int i = 0 ; i < indices.length ; i++){
array[indices[i]] = s.charAt(i);
}
return new String(array);
}
}
/*
//Your memory usage beats 48.63 % of java submissions.
//Your runtime beats 99.93 % of java submissions.
class Solution {
public String restoreString(String s, int[] indices) {
char[] array = new char[indices.length];
for(int i = 0 ; i < indices.length ; i++){
array[indices[i]] = s.charAt(i);
}
return String.copyValueOf(array);
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment