题解 | #最长无重复子数组#
最长无重复子数组
https://www.nowcoder.com/practice/b56799ebfd684fb394bd315e89324fb4
package main func maxLength(arr []int) int { ma := make(map[int]int) res := 0 st := -1 for i,val := range arr { pos,has := ma[val] if has { if st < pos { st = pos } } ma[val] = i if res < i - st { res = i - st } } return res }