【Leetcode】1528. Shuffle String
題目地址:
https://leetcode.com/problems/shuffle-string/
給定一個字串 s s s和一個陣列 a a a,要求返回一個新字串 t t t使得 t [ a [ i ] ] = s [ i ] t[a[i]]=s[i] t[a[i]]=s[i]。
程式碼如下:
public class Solution {
public String restoreString(String s, int[] indices) {
char[] str= new char[s.length()];
for (int i = 0; i < s.length(); i++) {
str[indices[i]] = s.charAt(i);
}
return new String(str);
}
}
時空複雜度 O ( l s ) O(l_s) O(ls)。
相關文章
- LeetCode Shuffle an Array(打亂陣列)LeetCode陣列
- [LeetCode] Rotate StringLeetCode
- Leetcode 481 Magical StringLeetCode
- Leetcode 8 String to Integer (atoi)LeetCode
- 【Leetcode】767. Reorganize StringLeetCode
- Leetcode 151 Reverse Words in a StringLeetCode
- leetcode 344. Reverse StringLeetCode
- [LeetCode] 678. Valid Parenthesis StringLeetCode
- [LeetCode] 844. Backspace String CompareLeetCode
- [LeetCode] 3163. String Compression IIILeetCode
- LeetCode 438. Find All Anagrams in a StringLeetCode
- LeetCode 394. Decode String All In OneLeetCode
- LeetCode String to Integer (atoi)(008)解法總結LeetCode
- LeetCode之Construct String from Binary Tree(Kotlin)LeetCodeStructKotlin
- LeetCode C++ 387. First Unique Character in a String【String/Hash Table】簡單LeetCodeC++
- [LeetCode] 1545. Find Kth Bit in Nth Binary StringLeetCode
- [LeetCode] 2825. Make String a Subsequence Using Cyclic IncrementsLeetCodeREM
- Spark shuffle調優Spark
- Hadoop Shuffle詳解Hadoop
- python---np.shufflePython
- [LeetCode] 1750. Minimum Length of String After Deleting Similar EndsLeetCodeMILA
- Leetcode 8. String to Integer (atoi) 字串轉整數 (atoi)LeetCode字串
- LeetCode 1209. Remove All Adjacent Duplicates in String II 有坑LeetCodeREM
- Spark學習——排序ShuffleSpark排序
- LeetCode C++ 316. Remove Duplicate Letters【Stack/Greedy/String】中等LeetCodeC++REM
- Spark的Shuffle總結分析Spark
- Flink Shuffle 3.0: Vision, Roadmap and Progress
- (轉)leetcode:Find All Anagrams in a String 滑動視窗方法總結LeetCode
- Spark-Shuffle過程概要參考Spark
- Browns lazy shuffle (布朗熊爬動屏保)
- 資料集shuffle的重要性
- Flink Sort-Shuffle 實現簡介
- Spark的兩種核心Shuffle詳解Spark
- String,String Builder,String Buffer-原始碼UI原始碼
- Failed to execute user defined function(anonfun$concatStr$1: (map<string,string>, string) => string)AIFunction
- 從 shuffle 看程式碼品味(面試題)面試題
- Spark Shuffle機制詳細原始碼解析Spark原始碼
- 【Spark篇】---Spark中Shuffle檔案的定址Spark