My Simple Solution in Python


  • 0
    A

    class Solution(object):
    def findDuplicate(self, nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    for i in xrange(len(nums)):
    if nums[abs(nums[i])] >= 0:
    nums[abs(nums[i])] = -nums[abs(nums[i])]
    else:
    return abs(nums[i])


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.