标签:++ mini lob maximum imu minimum class col rod
class Solution { public: int maxProduct(vector<int>& nums) { if(nums.empty()) return 0; if(nums.size() == 1) return nums[0]; int maxAll = nums[0]; //global maximum int maxLast = nums[0]; //maximum including last element int maxCur; //maximum including current element int minLast = nums[0]; //minimum including current element int minCur; //minimum including last element for(int i = 1; i < nums.size(); i ++) { maxCur = max(nums[i], max(maxLast*nums[i], minLast*nums[i])); minCur = min(nums[i], min(maxLast*nums[i], minLast*nums[i])); maxLast = maxCur; minLast = minCur; maxAll = max(maxAll, maxCur); } return maxAll; } };
标签:++ mini lob maximum imu minimum class col rod
原文地址:https://www.cnblogs.com/asenyang/p/9812655.html