Maximum Gap

May 29, 2017


leetcode 164

class Solution(object):
    def maximumGap(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        nums=sorted(nums)
        lens = len(nums)
        ret = 0
        if lens > 1:
            for i in range(lens - 1):
                diff = nums[i + 1] - nums[i]
                if diff > ret:
                    ret = diff
        return ret