LeetCode - Algorithms - 1528. Shuffle String

Problem

1528. Shuffle String

Java

1

1
2
3
4
5
6
7
8
9
class Solution {
public String restoreString(String s, int[] indices) {
char[] t = new char[s.length()];
for(int i=0;i<indices.length;i++) {
t[indices[i]] = s.charAt(i);
}
return new String(t);
}
}

Submission Detail

  • 399 / 399 test cases passed.
  • Runtime: 2 ms, faster than 28.58% of Java online submissions for Shuffle String.
  • Memory Usage: 41.9 MB, less than 5.19% of Java online submissions for Shuffle String.