1. 程式人生 > 其它 >Leetcode找自信題--重新排列字串

Leetcode找自信題--重新排列字串

技術標籤:資料結構與演算法

這是我最近刷到最簡單的題,我想也無需過多解釋,純粹找自信。

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