From c1e7790a7f0fe89bbd3e121ec7a8c314fabdece7 Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Wed, 3 Jul 2024 17:05:15 +0530 Subject: [PATCH] Create 1509. Minimum Difference Between Largest and Smallest Value in Three Moves --- ... Between Largest and Smallest Value in Three Moves | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 1509. Minimum Difference Between Largest and Smallest Value in Three Moves 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])) + )); + + } +};