For Absolute Beginner !!! Must See Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n- First we sort the whole array\n- with the help of for loop we will take
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n- First we sort the whole array\n- with the help of for loop we will take last and second last number present in sorted array\n- simply do the needful in the end\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\npublic:\n    int maxProduct(vector<int>& nums) {\n        sort(nums.begin(),nums.end());\n        int n=nums.size();\n        int p=0;\n        int q=0;\n        for(int i=0;i<n;i++)\n        {\n            p=nums[n-2];\n            q=nums[n-1];\n        }\n        return (p-1)*(q-1);\n    }\n};\n```
['C++']