diff --git a/1509. Minimum Difference Between Largest and Smallest Value in Three Moves b/1509. Minimum Difference Between Largest and Smallest Value in Three Moves new file mode 100644 index 0000000..4171a53 --- /dev/null +++ b/1509. Minimum Difference Between Largest and Smallest Value in Three Moves @@ -0,0 +1,11 @@ +class Solution { +public: + int minDifference(vector& nums) { + if(nums.size()<=4)return 0; + int n = nums.size(); + sort(nums.begin(),nums.end()); + return min((nums[n-4]-nums[0]),min((nums[n-3]-nums[1]),min((nums[n-2]-nums[2]),(nums[n-1]-nums[3])) + )); + + } +};