Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Use Startswith solution in Clear category for Count Substring Occurrences by U.V
def count_occurrences(main_str: str, sub_str: str) -> int:
return sum(main_str[i:].lower().startswith(sub_str.lower()) for i in range(len(main_str)-len(sub_str)+1))
Nov. 16, 2023