3.无重复字符的最长子串
3.无重复字符的最长子串
题解
简单题,不断维护窗口即可
代码
package main func lengthOfLongestSubstring(s string) int { wind := make(map[byte]int) result := 0 left, right := 0, 0 for i := 0; i < len(s); i++ { wind[s[i]]++ right++ for wind[s[i]] != 1 { wind[s[left]]-- left++ } if result < right-left { result = right - left } } return result }