Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple solution in Clear category for Minimum Window Substring by amandel
def window(line: str, pattern: str) -> tuple[int, int]:
# your code here
for i in range(1,len(line)+1):
for j in range(len(line)-i+1):
if set(pattern)<=set(line[j:j+i]):
return j, j+i
return -1, -1
print("Example:")
print(window("ADOBECODEBANC", "ABC"))
# These "asserts" are used for self-checking
assert window("ADOBECODEBANC", "ABC") == (9, 13)
assert window("ab", "a") == (0, 1)
assert window("ab", "A") == (-1, -1)
assert window("abcdef", "ace") == (0, 5)
assert window("MixEdCaSeScRiNgTrIcKy", "cSeR") == (8, 12)
print("The mission is done! Click 'Check Solution' to earn rewards!")
March 5, 2024