[C++] 2 solns
\n// Sorting Soln\n// Time: O(N.logN)\n// Space: O(1)\n\nclass Solution {\npublic:\n    int maxProduct(vector<int>& nums) \n    {\n        sort(nums.begin(), nu
```\n// Sorting Soln\n// Time: O(N.logN)\n// Space: O(1)\n\nclass Solution {\npublic:\n    int maxProduct(vector<int>& nums) \n    {\n        sort(nums.begin(), nums.end());\n        return (nums[nums.size() - 1] - 1) * (nums[nums.size() - 2] - 1);\n    }\n};\n```\n```\n// Heaps Soln\n// Time: O(N.logK)\n// Space: O(N)\n\nclass Solution {\npublic:\n    int maxProduct(vector<int>& nums) \n    {\n        priority_queue<int> maxheap;\n        for (int n : nums) {\n            maxheap.push(n);\n        }\n        \n        int a = maxheap.top();\n        maxheap.pop();\n        int b = maxheap.top();\n        \n        return (a - 1) * (b - 1);\n    }\n};\n```
['C', 'Sorting', 'Heap (Priority Queue)', 'C++']