Given two strings s and part, repeatedly remove the leftmost occurrence of part from s until s no longer contains part as a substring. Return the final string after all removals.
Constraints:
1≤ s.length ≤1000
1≤ part.length ≤1000
s and part consist of lowercase English letters.
Input: s = "daabcbaabcbc"-str, part = "abc"-str
Output: "dab"-str
Explanation: Removing the leftmost "abc" gives "daabcbc", removing the leftmost "abc" again gives "dabcbc", and removing it once more gives "dab". No "abc" remains.
Input: s = "axxxxyyyyb"-str, part = "xy"-str
Output: "ab"-str
Explanation: "xy" appears where the x’s meet the y’s, and each removal of the leftmost "xy" brings a new x and y together: "axxxxyyyyb" → "axxxyyyb" → "axxyyb" → "axyb" → "ab", after which no "xy" remains.
Input: s = "aaaaa"-str, part = "aa"-str
Output: "a"-str
Explanation: Repeatedly removing the leftmost "aa" turns "aaaaa" into "aaa" and then "a", after which "aa" no longer exists.
Input: s = "abababa"-str, part = "aba"-str
Output: "b"-str
Explanation: Removing the leftmost "aba" turns "abababa" into "baba", and removing the leftmost "aba" again turns "baba" into "b". No "aba" remains.
Input: s = "leetcode"-str, part = "code"-str
Output: "leet"-str
Explanation: Removing the leftmost (and only) occurrence of "code" from "leetcode" gives "leet".
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem: