nums
.nums[i]
, compute the index index = abs(nums[i]) - 1
(to account for 0-based indexing).nums[index]
is positive, negate it to mark that the number index + 1
has been seen.i
, if nums[i]
is positive, it means the number i + 1
was not seen, so add i + 1
to the result list.