题目:
题解:
func findDuplicates(nums []int) (ans []int) {for _, x := range nums {if x < 0 {x = -x}if nums[x-1] > 0 {nums[x-1] = - nums[x-1]} else {ans = append(ans, x)}}return
}
题目:
题解:
func findDuplicates(nums []int) (ans []int) {for _, x := range nums {if x < 0 {x = -x}if nums[x-1] > 0 {nums[x-1] = - nums[x-1]} else {ans = append(ans, x)}}return
}