[Java/C++/Python] Sort
Explanation\nSort the input A\nThe result must be the minimum difference of 2 adjacent elements.\n\nWe put A[0] ... A[i - 1] in array nums1\nWe put A[i] ... A[n
# **Explanation**\nSort the input `A`\nThe result must be the minimum difference of 2 adjacent elements.\n\nWe put `A[0] ... A[i - 1]` in array `nums1`\nWe put `A[i] ... A[n - 1]` in array `nums2`\n\nso `|max(nums1) - min(nums2)| = A[i] - A[i - 1]`,\nonly need to find out `min(A[i] - A[i - 1])`\n<br>\n\n# **Complexity**\nTime `O(sort)`\nSpace `O(sort)`\n<br>\n\n**Java**\n```java\n    public int findValueOfPartition(int[] A) {\n        Arrays.sort(A);\n        int res = A[1] - A[0], n = A.length;\n        for (int i = 2; i < n; i++)\n            res = Math.min(res, A[i] - A[i - 1]);\n        return res;\n    }\n```\n\n**C++**\n```cpp\n    int findValueOfPartition(vector<int>& A) {\n        sort(A.begin(), A.end());\n        int res = A[1] - A[0], n = A.size();\n        for (int i = 2; i < n; i++)\n            res = min(res, A[i] - A[i - 1]);\n        return res;\n    }\n```\n\n**Python**\n```py\n    def findValueOfPartition(self, A: List[int]) -> int:\n        A.sort()\n        return min(A[i] - A[i - 1] for i in range(1, len(A)))\n```\n
['C', 'Python', 'Java']