✅ Beats 100 % | Solution in 2 lines C++ | 🤑 Greedy approach.
Intuition\n Describe your first thoughts on how to solve this problem. \n We need to maximize the left operand, and minimize the right operant of the - operator
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n* We need to maximize the left operand, and minimize the right operant of the **- operator**\n* So we can multiply the maximum two values in the given list\n* and subtract from the result the result of multipling the minimum two values.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n* All we need to do is to sort the given list. \n* then return the product of the last two element - the product of the first two elements.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n1. O(nlgn) for the sort function.\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n1. O(1)\n# Code\n```\n#include <bits/stdc++.h>\n#pragma GCC optimize("O3")\n#pragma GCC optimize("Ofast", "inline", "ffast-math", "unroll-loops", "no-stack-protector")\n#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native", "f16c")\nstatic const auto DPSolver = []()\n{ std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); return \'c\'; }();\nusing namespace std;\nclass Solution {\npublic:\n    int maxProductDifference(vector<int>& nums) {\n        DPSolver;\n        sort(nums.begin(), nums.end());\n        return (nums[nums.size()-1]* nums[nums.size()-2]) - (nums[0]*nums[1]); \n    }\n};\n```
['Array', 'Greedy', 'Sorting', 'C++']