Leetcode 1651 Solution

This article provides solution to leetcode question 1651 (shuffle-string).

https://leetcode.com/problems/shuffle-string

Solution

class Solution:
    def restoreString(self, s: str, indices: List[int]) -> str:
        n = len(s)
        
        ans = [0] * n
        
        for ch, index in zip(s, indices):
            ans[index] = ch
        
        return "".join(ans)