- See Code
O(n)
class Solution:
def findReplaceString(self, S: str, indexes: List[int], sources: List[str], targets: List[str]) -> str:
for i, s, t in sorted(zip(indexes, sources, targets), reverse=True):
S = S[:i] + t + S[i + len(s):] if S[i:i + len(s)] == s else S
return S