Think we surely have to negate anytime we are given an array with values from 1 to the length of array. If anyone has a better idea, will be happy to hear.

The steps followed in this is:

- Negate each number while traversing
- Run again and find the index that is not negated.

```
List<Integer> result = new ArrayList<Integer>();
for( int i=0;i< nums.length; i++){
int index = nums[i];
if(nums[Math.abs(index)-1] > 0){
nums[Math.abs(index)-1]= -nums[Math.abs(index)-1];
}
}
for(int j =1 ;j <= nums.length ; j++){
if(nums[j-1] > 0){
result.add(j);
}
}
return result;
}
```