Remove All Occurrences of a Substring

Given two strings 's' and 'part', repeatedly remove the leftmost occurrence of the substring 'part' from 's' until it is no longer present. Return the resulting string 's' after all occurrences have been removed.

Constraints

  • 1 <= s.length <= 1000
  • 1 <= part.length <= 1000
  • s and part consist of lowercase English letters.
Saving… · 2 lines
class Solution:
def removeOccurrences(self, s: str, part: str) -> str:
Console

Click Run to execute sample tests.