I used slide window algorithm.
Defining a set first to fit the substring during the window sliding process.
When there's repeat letter appears in the window, then the set will delete the very left letter and slide toward right one letter, then check repeating again, until there's no repeat letter in the window. Recording every length after checking, and store the length in res. If res has a bigger number, it will adopt the bigger one.
Time complexity is O(n) since it only traverse once.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)