Skip to content

Commit e650410

Browse files
Create 1509-minimum-difference-between-largest-and-smallest-value-in-three-moves.java
1 parent 40c3619 commit e650410

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int minDifference(int[] nums) {
3+
if(nums.length <= 4)
4+
return 0;
5+
6+
Arrays.sort(nums);
7+
int res = Integer.MAX_VALUE;
8+
for(int l = 0; l < 4; l++){
9+
int r = nums.length - 4 + l;
10+
res = Math.min(res, nums[r] - nums[l]);
11+
}
12+
return res;
13+
}
14+
}

0 commit comments

Comments
 (0)