solved with just basics(noobie technique)
Intuition\n Describe your first thoughts on how to solve this problem. \nThe key observation is that by removing three elements from the array, we can only remo
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe key observation is that by removing three elements from the array, we can only remove elements from either the start (smallest elements) or the end (largest elements) of the sorted array. This is because removing elements from anywhere else would not help in minimizing the difference between the remaining maximum and minimum values. Thus, the solution involves sorting the array and considering the best possible scenarios where we remove three elements from either end.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nHandle Small Arrays: If the array size is less than or equal to 4, then we can remove all elements to make the array empty or with a single element, hence the minimum difference is 0.\n\nSort the Array: Sorting the array helps us easily access the smallest and largest elements.\n\nConsider Possible Removals:\n\nRemove the three largest elements.\nRemove the two largest and one smallest element.\nRemove the one largest and two smallest elements.\nRemove the three smallest elements.\n\n# Complexity\n- Time complexity: O(NLogN)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minDifference(vector<int>& nums) {\n        int n = nums.size();\n        if(n<=4)\n        {\n            return 0;\n        }\n        sort(nums.begin(),nums.end());\n        vector<int> ans;\n        \n       \n        ans.push_back(abs(nums[n-4]-nums[0]));\n        ans.push_back(abs(nums[3]-nums[n-1]));\n        ans.push_back(abs(nums[2]-nums[n-2]));\n        ans.push_back(abs(nums[1]-nums[n-3]));\n        sort(ans.begin(),ans.end());\n        return ans[0];\n    }\n};\n```
['Array', 'Sorting', 'C++']