Find And Replace in String LeetCode solution in Python
1class Solution:2def findReplaceString(3self, s: str, indices: List[int], sources: List[str], targets: List[str]4) -> str:56inputs = list(zip(indices, sources, targets))7inputs.sort(key=lambda x: x[0])89offset = 010for idx, src, tgt in inputs:11idx += offset12if s[idx : idx + len(src)] != src:13print("hi")14print(idx)15continue1617offset += len(tgt) - len(src)18s = s[:idx] + tgt + s[idx + len(src) :]1920return s