Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ return (3* sum(set(nums)) - sum(nums))/ (3*len(set(nums)) - len(nums))

the question does not say the number show once or twice. If only show once, your solution is incorrect.

Good point, actually, if only show once, above solution is correct, but if show twice, it is wrong. I have modified the solution.

return (3* sum(set(nums)) - sum(nums))/2

At first, I also used 2, but as ArkLiu commented, there is no given condition that the number show up twice. Strictly, it may show up any time bigger than 1.

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