题目:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/

func lengthOfLongestSubstring(s string) int {
	sLen := len(s)
	if sLen <= 1 {
		return sLen
	}
	tempMap := make([]int, 256) // 字符词频表
	right := 0
	maxLen := 0
	for left := 0; left < sLen; left++ {
		for ; right < sLen && tempMap[s[right]] == 0; right++ {
			tempMap[s[right]]++
		}
		fmt.Println(tempMap)
		maxLen = max(maxLen, right - left)
		if right == sLen {
			break
		}
		tempMap[s[left]]--
	}
	return maxLen
}

func max(x, y int) int {
    if x < y {
        return y
    }
    return x
}

为什么我自己写出来的跟这个性能差这么多,哎, 去抄10遍吧!