simple golang solution


  • 0
    S
    func findMaxConsecutiveOnes(nums []int) int {
    	result := 0
    	curCon := 0
    	for _, num := range nums{
    		if num == 1 {
    			curCon++
    			if curCon > result {
    				result = curCon
    			}
    		} else {
    			curCon = 0
    		}
    	}
    	return result
    }
    

Log in to reply
 

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