close
Given a string s and an integer array 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.
解題: 給一字串與一數字陣列,要求將字串以數字陣列順序重構 按照要求直覺進行coding python code:
class Solution: def restoreString(self, s: str, indices: List[int]) -> str: dicts={} for i,j in zip(s,indices): dicts[j]=i correct=[] for a in range(len(indices)): correct.append(dicts[a]) return "".join(s for s in correct)
文章標籤
全站熱搜
留言列表