Skip to content

Commit c1e7790

Browse files
authored
Create 1509. Minimum Difference Between Largest and Smallest Value in Three Moves
1 parent 0b9ee3c commit c1e7790

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
int minDifference(vector<int>& nums) {
4+
if(nums.size()<=4)return 0;
5+
int n = nums.size();
6+
sort(nums.begin(),nums.end());
7+
return min((nums[n-4]-nums[0]),min((nums[n-3]-nums[1]),min((nums[n-2]-nums[2]),(nums[n-1]-nums[3]))
8+
));
9+
10+
}
11+
};

0 commit comments

Comments
 (0)