例:寻找最长不含有重复字符的字串
★ abcabcbb ——> abc
★ bbbbb ——> b
★ pwwkew ——> wke
核心代码示例
func lengthOfNonRepeatingSubStr(s string)int{

lastOccurred := make(map[rune]int)
start := 0
maxLength := 0
for i, ch := range []rune(s) {

if lastI, ok := lastOccurred[ch]; ok && lastI >= start {
start = lastI + 1
}
if i - start + 1 > maxLength {
maxLength = i - start + 1
}
lastOccurred[ch] = i
}
return maxLength
}