Python, reasonable answer with O(n) space and time


  • 0
    4
        expected_sum = len( nums ) * ( len( nums ) + 1 ) / 2
        actual_sum = sum( nums )
        _set = set([])
        for i in nums:
            if i in _set:
                return [ i, expected_sum - actual_sum + i ]
            _set.add( i )
    

Log in to reply
 

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