Problem statement

https://binarysearch.com/problems/Largest-Gap/

Solution

Just sort and do what is asked. Notice, that there is also O(n) time complexity solution.

Complexity

It is O(n log n) for time and O(n) for space.

Code

class Solution:
    def solve(self, nums):
        nums = sorted(nums)
        return max(y - x for x, y in zip(nums, nums[1:]))