public class Solution {
public string RestoreString(string s, int[] indices) {
var sb = new StringBuilder();
for (var i = 0; i < indices.Length; ++i) {
var charPosition = Array.IndexOf(indices, i);
sb.Append(s[charPosition]);
}
return sb.ToString();
}
}
Source: https://leetcode.com/problems/shuffle-string/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Monday, February 15, 2021
Leetcode Everyday: 1528. Shuffle String. Easy
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment