不修改数组找出重复的数字-golang
func duplicateInArray(nums []int) int {
l, r := 1, len(nums)-1
for l < r{
mid := (l+r)>>1
var count int
for _, v := range nums{
if v >= l && v <= mid{
count++
}
}
if count > mid-l+1{
r = mid
continue
}
l = mid+1
}
return r
}