C++ ONE PASS 100% time 99.9% space (with explanation)
Here variable a will store max value of array nums, while b will store 2nd max value\n\n\nclass Solution {\npublic:\n    int maxProduct(vector<int>& nums) {\n  
Here variable `a` will store max value of array `nums`, while `b` will store 2nd max value\n\n```\nclass Solution {\npublic:\n    int maxProduct(vector<int>& nums) {\n        int a = 0, b = 0;\n        for (int i = 0;i < nums.size();i++) {\n            if (nums[i] > a) {\n                b = a;  // delegate previous max value to 2nd max value\n                a = nums[i];  // set new max value\n            } else if (nums[i] > b) {\n                b = nums[i];\n            }\n        }\n        return (a-1)*(b-1);\n    }\n};\n```
[]