category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

152. Maximum Product Subarray , kadane’s variant, medium

Code ```cpp class Solution { public: int maxProduct(vector& nums) { int mx, mn, ans; ans = mx = mn = nums.front(); for (int i = 1; i < nums.size(); i++) { if (nums[i] < 0) swap(mx, mn); mx = max(nums[i], mx * nums[i]); mn = min(nums[i], mn * nums[i]); ans = max({ans, mx, mn}); } return ans; } }; ``` </details>