LeetCode 1528. Shuffle String (重新排列字符串)

题目标签:Sort

  建立一个 char array,把每一个位置上的字母 放入char array,具体看code。

Java Solution: 

Runtime:  1 ms, faster than 100.00% 

Memory Usage: 39.3 MB, less than 94.79%

完成日期:8/11/2020

关键点:char []

class Solution {
    public String restoreString(String s, int[] indices) {
        
        char[] newWord = new char[indices.length]; 
        
        for(int i=0; i<indices.length; i++) {
            newWord[indices[i]] = s.charAt(i);
        }
        
        return new String(newWord);
    }
}

参考资料:n/a

LeetCode 题目列表 - LeetCode Questions List

题目来源:https://leetcode.com/

原文地址:https://www.cnblogs.com/jimmycheng/p/13488474.html