def findDuplicates(nums):
    """
    :type nums: List[int]
    :rtype: List[int]
    """
    nums = sorted(nums)
    ans = []
    for i in range(len(nums) - 1):
        if nums[i] == nums[i + 1]:
            ans.append(nums[i])
    return ans


findDuplicates([2, 4, 3, 4, 5, 1, 2])

278d1bfe278e34a5d21f8651c8f25696de312c95
<mask token>

def findDuplicates(nums):
    """
    :type nums: List[int]
    :rtype: List[int]
    """
    nums = sorted(nums)
    ans = []
    for i in range(len(nums) - 1):
        if nums[i] == nums[i + 1]:
            ans.append(nums[i])
    return ans


<mask token>

def findDuplicates(nums):
    """
    :type nums: List[int]
    :rtype: List[int]
    """
    nums = sorted(nums)
    ans = []
    for i in range(len(nums) - 1):
        if nums[i] == nums[i + 1]:
            ans.append(nums[i])
    return ans


findDuplicates([2, 4, 3, 4, 5, 1, 2])
