Saturday, June 24, 2023

Largest Gap

Given an array of integers, return the largest gap between the sorted elements of the array.

For example, consider the array:

[9, 4, 26, 26, 0, 0, 5, 20, 6, 25, 5] ... in which, after sorting, the array becomes:

[0, 0, 4, 5, 5, 6, 9, 20, 25, 26, 26] ... so that we now see that the largest gap in the array is between 9 and 20 which is 11.



No comments:

Post a Comment