Easy C++ Solution


  • 0
    Q
    class Solution {
    public:
        int findMaxConsecutiveOnes(vector<int>& nums) {
            int point = -1,res = 0;
    		for (int i = 0; i < nums.size();i++)
    		{
    			int begin = i;
    			while (i<nums.size() && nums[i] == 1)
    			{
    				res = max(res, i - begin + 1);
    				i++;
    			}
    		}
    		return res;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.