Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed:


	Find the leftmost occurrence of the substring part and remove it from s.


Return s after removing all occurrences of part.

A substring is a contiguous sequence of characters in a string.

&nbsp;
Example 1:

Input: s = "daabcbaabcbc", part = "abc"
Output: "dab"
Explanation: The following operations are done:
- s = "daabcbaabcbc", remove "abc" starting at index 2, so s = "dabaabcbc".
- s = "dabaabcbc", remove "abc" starting at index 4, so s = "dababc".
- s = "dababc", remove "abc" starting at index 3, so s = "dab".
Now s has no occurrences of "abc".


Example 2:

Input: s = "axxxxyyyyb", part = "xy"
Output: "ab"
Explanation: The following operations are done:
- s = "axxxxyyyyb", remove "xy" starting at index 4 so s = "axxxyyyb".
- s = "axxxyyyb", remove "xy" starting at index 3 so s = "axxyyb".
- s = "axxyyb", remove "xy" starting at index 2 so s = "axyb".
- s = "axyb", remove "xy" starting at index 1 so s = "ab".
Now s has no occurrences of "xy".


&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 1000
	1 &lt;= part.length &lt;= 1000
	s​​​​​​ and part consists of lowercase English letters.


class Solution:
    def removeOccurrences(self, s: str, part: str) -> str:
        n=len(part)
        while part in s:
            i=s.index(part)
            s=s[:i]+s[i+n:]
        return s
class Solution {
    public String removeOccurrences(String s, String part) {
        // s.replace(part,"");
        // System.out.println(s);
        
        while(s.contains(part))
        {
            s=s.replaceFirst(part,"");
        }
        return s;
    }
}
class Solution {
public:
    bool check(stack<char> st, string part){
        int n2 = part.length();
        int j = n2-1;
        while( j >=0 and st.top() == part[j]){
            st.pop();
            j--;
        }
        return (j == -1);
    }
    string removeOccurrences(string s, string part) {
        int n1 = s.length() , n2 = part.length();
        stack<char>st;
        string str = "" ;
        for(int i=0;i<n1;++i){
            st.push(s[i]);
            if(st.size() >= n2){
                if(check(st,part)){
                    int ct = n2;
                    while(ct--){
                        st.pop();
                    }
                }
            }
        }
        string res = "";
        while(!st.empty()){
            res += st.top();
            st.pop();
        }
        reverse(res.begin(),res.end());
        return res;
    }
};
var removeOccurrences = function(s, part) {
    let n =part.length
    const reduceString = (s)=>{
        let searchPart =s.indexOf(part)
        if (searchPart<0)
            return s
        s= s.split('')
        s.splice(searchPart, n)
        s=s.join('')
        return reduceString(s)

    }
    return reduceString(s)
};
Remove All Occurrences of a Substring