The current problem I'm having is that when the code runs it shows me "None" in the terminal.
/usr/local/bin/python3.12/Users/jaredmccarthy/Desktop/2025/ejercicios_leetcode.py
None
Process finished with exit code 0
I want find the length of the longest substring without duplicate characters using the siding window algorithm.
First I had tried with a pointer to the start of the string and then with a max_length but with a while, and what happens is that I could not go through all the elements using only the while and that is why I tried to change to the "for" and this time using two pointers, one that stays from the start and the other to go through all the elements and when they reach the window if they are repeated it takes them out and if not it puts them inside the window, do I make myself understood?
Here is my code:
def longest_substring(s):
ventana = set(s)
max_longitud = 0
inicio = 0
for fin in range(len(s)):
if fin != len(ventana):
ventana.add(fin)
max_longitud += 1
if fin == len(s):
ventana.remove(inicio)
inicio += 1
if __name__ == "__main__":
s = "abcabcbb"
print(longest_substring(s))