Largest Gap
Imagine the numbers in nums sorted from smallest to largest. Return the largest difference between two neighbors in that sorted order. If there is only one number, return 0.
Example 1
nums [10,1,4,20]
returns 10
Sorted: 1, 4, 10, 20. The gaps are 3, 6 and 10.
Constraints
1 <= len(nums) <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Latest PeakEasy
- Merge and SortEasy
- Missing NumbersEasy
- Most Common ValueEasy
- Most Different PositionEasy
- Outlier CountEasy
- Pair DifferencesEasy
- Percent ChangeEasy