easy short efficient clean code
The partitions are actually subsequences. Lets say we partition arr into :\npa = [x1, x2, .. xm]\npb = [y1, y2, .. yn]\nThe answer is abs(xm-y1);\nThe only choi
The partitions are actually subsequences. Lets say we partition arr into :\npa = [x1, x2, .. xm]\npb = [y1, y2, .. yn]\nThe answer is abs(xm-y1);\nThe only choices that matter are those of xm and y1 ; rest do not.\nThus we need to check for every possible xi, the closest yj to form (xm, y1) = (xi, yj).\n```\nclass Solution {\npublic:\n    int findValueOfPartition(vector<int>&v) {\n        int n=v.size();\n        sort(begin(v), end(v), greater<int>());\n        int ans=INT_MAX;\n        for(int i=0;i<n-1;++i){\n            ans=min(ans, v[i]-v[i+1]);\n        }\n        return ans;\n    }\n};\n```
['Greedy', 'C', 'Sorting']