> For the complete documentation index, see [llms.txt](https://chiragjain.gitbook.io/neetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chiragjain.gitbook.io/neetcode/442-find-all-duplicates-in-an-array/code.md).

# CODE

```python
class Solution:
    def findDuplicates(self, nums: List[int]) -> List[int]:
        result = []
        for num in nums:
            idx = abs(num) - 1
            # If we are trying to mark a number that is already 
            # negative it means that we have seen that index 
            # before and hence the number is duplicate
            if nums[idx] < 0:
                result.append(idx + 1)
            # Seeing index for first time, mark negative
            else:
                nums[idx] *= -1
        return result
            
        
```
