The concept here is to negate each number's index as the input is 1 <= a[i] <= n (n = size of array). Once a value is negated, if it requires to be negated again then it is a duplicate.

'''

public List<Integer> findDuplicates(int[] nums) {

```
List<Integer> newList = new ArrayList<Integer>(); // creating a new List
for(int i=0;i<nums.length;i++){
int index =Math.abs(nums[i]); // Taking the absolute value to find index
if(nums[index-1] >0){
nums[index-1] = - nums[index-1];
}else{
// If it is not greater than 0 (i.e) negative then the number is a duplicate
newList.add(Math.abs(nums[i]));
}
}
return newList;
}
```