Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ee59919

Browse files
164. Maximum Gap (java)
1 parent 48020d2 commit ee59919

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int maximumGap(int[] nums) {
3+
int length = nums.length;
4+
if(length <2) return 0;
5+
Arrays.sort(nums);
6+
int max=0;
7+
for(int i = 1; i< length; i++) max = Integer.max(nums[i] - nums[i - 1], max);
8+
return max;
9+
}
10+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /