c++(16ms 99,38%) time O(n) clean, one pass solution
Runtime: 16 ms, faster than 99.38% of C++ online submissions for Maximum Product Difference Between Two Pairs.\nMemory Usage: 20.3 MB, less than 62.17% of C++ o
Runtime: 16 ms, faster than 99.38% of C++ online submissions for Maximum Product Difference Between Two Pairs.\nMemory Usage: 20.3 MB, less than 62.17% of C++ online submissions for Maximum Product Difference Between Two Pairs.\n\n```\nclass Solution {\npublic:\n  int maxProductDifference(vector<int>& nums){\n    sort(nums.begin(), nums.begin() + 4);              //sorting ONLY FIRST FOUR NUMBERS               \n    int mm = nums[0], m = nums[1], M = nums[2], MM = nums[3];\n    \n    for(int i = 4; i != nums.size(); i++)\n      if     (nums[i] >= MM) M = MM, MM = nums[i];     //for case: mm , m , M, MM, number , else =>\n      else if(nums[i] >   M)          M = nums[i];     //for case: mm , m , M, number, MM , else =>\n      else if(nums[i] <= mm) m = mm, mm = nums[i];     //for case: number, mm , m , M, MM , else =>\n      else if(nums[i] <   m)          m = nums[i];     //for case: mm , number, m , M, MM \n    \n    return MM*M - mm*m;\n  }\n};\n```
['C', 'C++']