1651. Shuffle String
My accepted Python solution to LeetCode problem 1651, Shuffle String, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.5MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.5MB, accepted 2025-12-29.
class Solution:
def restoreString(self, s: str, indices: List[int]) -> str:
result = [''] * len(s)
for i, idx in enumerate(indices):
result[idx] = s[i]
return ''.join(result)