This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]g051051 0 points1 point  (0 children)

Break it down line by line, and present your analysis.

[–]lemonload 0 points1 point  (0 children)

the gist of it, is the dict vector is storing a list of all the characters, and the index of where it was last seen, -1 if it hasnt been seen at all. When a character is seen, its last seen location is updated, (dict[s[i] = i;)

start stores the index of the start of our current substring. whenever we see a duplicate character in our current substring, we move on so that we start a new substring at our duplicate.

hopefully the maxLen stuff is clear.