simple python solution beats 81%


  • -1
    X
    class Solution(object):
        def maximumGap(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            l = len(nums)
            if l<=1:
                return 0
            else:
                s = []
                nums.sort()
                for i in range(l-1):
                    x = nums[i+1]-nums[i]
                    s.append(x)
                return max(s)
    

Log in to reply
 

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