text and a batch of patches. Patch i is described by a position positions[i] (0-based), an expected fragment expected[i] and a new fragment replacements[i].
A patch applies only if the original text really contains expected[i] starting at positions[i]. In that case the fragment is replaced with replacements[i]. If the fragment does not match (or does not fit in the string), the patch is skipped.
All patches are applied at once: positions always refer to the original string, never to a partly edited one. The fragments of applicable patches are guaranteed not to overlap.
Return the string after all patches.text="sunnyday", positions=[0, 5], expected=["sun", "day"], replacements=["fun", "night"] → 'funnynight'
Both patches apply: "sun" sits at position 0 and "day" at position 5. The result is "fun" + "ny" + "night".
text="overflow", positions=[4, 0], expected=["flaw", "ov"], replacements=["x", "und"] → 'underflow'
Position 4 holds "flow", not "flaw", so the first patch is skipped. The second one matches: "ov" becomes "und".
text="abc", positions=[2], expected=["cd"], replacements=["z"] → 'abc'
text and expected[i] consist of lowercase English lettersreplacements[i] consist of English letters and digitstext="sunnyday", positions=[0, 5], expected=["sun", "day"], replacements=["fun", "night"]
'funnynight'
Run checks the first 3 tests in your browser. Submit checks all 93 tests on the server, hidden ones included.