Created
December 3, 2020 21:18
-
-
Save kingsamadesu/d0fd91a1b2107d16e080edd50afee3b8 to your computer and use it in GitHub Desktop.
1528. Shuffle String -with java- (leetcode.com)
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
/* | |
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