Given a binary array nums, return the maximum number of consecutive1‘s in the array.
1 2 3 4 5 6 7 8
classSolution { public: intfindMaxConsecutiveOnes(vector<int>& nums){ int res = 0, now = 0; for(auto& x : nums) res = max(res, now = x ? now + 1 : 0); return res; } };