Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int maximumGap(int[] numbers) {
- if (numbers.length < 1)
- return 0;
- Arrays.sort(numbers);
- int previous = numbers[0];
- int current;
- int maximum = 0;
- for (int i = 1; i < numbers.length; i++) {
- current = numbers[i];
- if (maximum < current - previous)
- maximum = current - previous;
- previous = current;
- }
- return maximum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement