LeetCode - Problems - Algorithms - 1528. Shuffle String
Problem Description
Given a string s and an integer indices of the same length.
The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.
Return the shuffled string.
Example:
Constraints:
My Solution (Python)
class Solution(object):
def restoreString(self, s, indices):
"""
:type s: str
:type indices: List[int]
:rtype: str
"""
answer = list(s)
index = 0
for i in indices:
answer[i] = s[index]
index += 1
return "".join(answer)
'Problem solving > Algorithms' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[LeetCode] 1678. Goal Parser Interpretation (Python) (0) | 2021.01.10 |
---|---|
[LeetCode] 1603. Design Parking System (Python) (0) | 2021.01.10 |
[LeetCode] 1512. Number of Good Pairs (Python) (0) | 2021.01.10 |
[LeetCode] 1470. Shuffle the Array (Python) (0) | 2021.01.10 |
[LeetCode] 1365. How Many Numbers Are Smaller Than the Current Number (Python) (0) | 2021.01.10 |