Python, Using string method to solve this problem

  • 0
    class Solution(object):
        def findMaxConsecutiveOnes(self, nums):
            :type nums: List[int]
            :rtype: int
            str_num = ''.join(str(e) for e in nums)
            str_num = str_num.split('0')
            return max([len(s) for s in str_num])

Log in to reply

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