Very simple Python 4 line solution

  • 0

    I don't know if it satisfies the request of this question
    But it's accepted

    def findDuplicate(self, nums):
          f = -1
          for i,v in enumerate(sorted(nums)):
              if f == v: return f
              f = v

Log in to reply

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