2 methods || sorting || priority queue || Brute force to optimized
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n    1. sort and access 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n    1. sort and access last 2 elements\n    2. use max heap i.e. priority queue and acess top 2 elements. \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n         sorting: O(nlogn)\n         priority queue: O(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n         sorting: O(1)\n         priority queue: O(n)\n\n# Code\n```\nclass Solution {\npublic:\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\n```\n```\nclass Solution {\npublic:\n    int maxProduct(vector<int>& nums) {\n       priority_queue<int>pq;\n       for(int i:nums) pq.push(i);\n       int x=pq.top();\n       pq.pop();\n       int y=pq.top();\n       return (x-1)*(y-1);\n    }\n};\n```
['Array', 'Sorting', 'Heap (Priority Queue)', 'C++']