C++ | Largest and second Largest | Commented with explanation
Find the largest and second largest from the array, by traversing the array once\n It is possible that the largest number = second largest number, eg. [1,5,4,5]
* Find the largest and second largest from the array, by traversing the array *once*\n* It is possible that the largest number = second largest number, eg. ```[1,5,4,5]``` \n\n```\nclass Solution {\npublic:\n    int maxProduct(vector<int>& nums) \n    {\n        int max1 = INT_MIN; //largest number\n        int max2 = INT_MIN; //second largest number\n        \n        for(int i=0; i<nums.size(); i++)\n        {\n            int val = nums[i];\n            \n            if(val > max1) //value greater than max1, update second largest with largest so far \n            {\n                max2 = max1;\n                max1 = val;\n            }\n            \n            else if(val <= max1 && val > max2) //equality holds as max1 = max2 can be possible\n            {\n                max2 = val;\n            }\n        }\n        \n        return (max1-1)*(max2-1);\n    }\n};\n```\n\n**Upvote if this helped!**
['C', 'C++']