Golang | Leetcode Golang题解之第448题找到所有数组中消失的数字
题目:
题解:
func findDisappearedNumbers(nums []int) (ans []int) {
n := len(nums)
for _, v := range nums {
v = (v - 1) % n
nums[v] += n
}
for i, v := range nums {
if v <= n {
ans = append(ans, i+1)
}
}
return
}