[Java/C++/Python] Change Biggest or Smallest
Intuition\nChange the biggest or the smallest,\nto be other existing number.\n\n\n# Explanation\nChange two biggest,\nthen the high score is A[n-3] - A[0]\n\nCh
# **Intuition**\nChange the biggest or the smallest,\nto be other existing number.\n<br>\n\n# **Explanation**\nChange two biggest,\nthen the high score is `A[n-3] - A[0]`\n\nChange the biggest and the smallest,\nthen the high score is `A[n-2] - A[1]`\n\nChange two smallest,\nthen the high score is `A[n-1] - A[2]`\n\nFor the low score,\nwe can always have 2 same numbers,\nso low score is 0.\n<br>\n\n# **Complexity**\nTime `O(sort)`\nSpace `O(sort)`\n\nAlso we can one pass,\nand find out the 3 biggest and 3 smallest in `O(n)`\n<br>\n\n**Java**\n```java\n    public int minimizeSum(int[] A) {\n        int n = A.length;\n        Arrays.sort(A);\n        return Math.min(Math.min(A[n - 1] - A[2], A[n - 3] - A[0]), A[n - 2] - A[1]);\n    }\n```\n\n**C++**\n```cpp\n    int minimizeSum(vector<int>& A) {\n        int n = A.size();\n        sort(A.begin(), A.end());\n        return min({A[n - 1] - A[2], A[n - 3] - A[0], A[n - 2] - A[1]});\n    }\n```\n\n**Python**\n```py\n    def minimizeSum(self, A):\n        A.sort()\n        return min(A[-1] - A[2], A[-2] - A[1], A[-3] - A[0])\n```\n
['C', 'Python', 'Java']