C++ | 2 liner | 0ms
Sort nums\n2. multiply the last two nums \n (since they\'re the max and second max)\n\nc++\n    int maxProduct(vector<int>& nums) {\n        sort(nums.begin(),n
1. Sort nums\n2. multiply the last two nums \n (since they\'re the max and second max)\n\n```c++\n    int maxProduct(vector<int>& nums) {\n        sort(nums.begin(),nums.end());\n        return (nums[nums.size()-1]-1)*(nums[nums.size()-2]-1);\n```\n\n## Another Method\n```c++\nint maxProduct(vector<int>& nums) {\n        int max1 = 0;\n        int max2 = 0;\n\n        for(int n : nums)\n            if(n > max1){\n                max2 = max1;\n                max1 = n;\n            }else if(n > max2)\n                max2 = n;\n\n        return (max1-1)*(max2-1);\n```
['C++']