Another O(n) approach without negating

public List<Integer> findDuplicates(int[] nums) {
for(int i = 0; i < nums.length; i++) {
// put nums[i] to it's right place if the right place is not already nums[i]
while(i != nums[i]-1 && nums[i] != nums[nums[i]-1]) {
int temp = nums[i];
nums[i] = nums[nums[i]-1];
nums[temp-1] = temp;
}
}
List<Integer> result = new ArrayList<Integer>();
for(int i = 0; i < nums.length; i++) {
if(i != nums[i]-1) result.add(nums[i]);
}
return result;
}