Funny python solution with set, but may not be used in the interview.

  • 0
    class Solution(object):
    def findDuplicate(self, nums):
        :type nums: List[int]
        :rtype: int
        x = set(nums)
        num_x = len(x)
        return (sum(nums)-sum(x))/(len(nums)-num_x)

  • 0

    And this, ladies and gentlemen, is how you present an "invalid" solution and get an upvote instead of a downvote :-)

    Funny indeed (well, at least I laughed), and interesting. I'd omit the num_x variable, though.

Log in to reply

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