You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solution/1500-1599/1528.Shuffle String/README_EN.md
+41-9Lines changed: 41 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,11 @@ tags:
57
57
58
58
<!-- solution:start -->
59
59
60
-
### Solution 1
60
+
### Solution 1: Simulation
61
+
62
+
We create a character array or string $\textit{ans}$ of the same length as the input string, then iterate through the string $\textit{s}$ and place each character $\textit{s}[i]$ at position $\textit{indices}[i]$ in $\textit{ans}$. Finally, we join the character array or string $\textit{ans}$ to form the final result and return it.
63
+
64
+
The time complexity is $O(n)$ and the space complexity is $O(n)$, where $n$ is the length of the string.
0 commit comments