#442

class Solution:
    def get_duplicates(self, nums):
        if not nums:
            return None
        result = []
        for num in nums:
            index = abs(num) - 1
            if nums[index] < 0:
                result.append(abs(num))
            else:
                nums[index] *= -1
        return result

solution = Solution()
nums = [4, 3, 2, 7, 8, 2, 4, 1]
print(solution.get_duplicates(nums))