{"id":209,"date":"2018-08-27T21:39:21","date_gmt":"2018-08-27T13:39:21","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=209"},"modified":"2018-11-27T17:40:01","modified_gmt":"2018-11-27T09:40:01","slug":"485-max-consecutive-ones","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=209","title":{"rendered":"485. Max Consecutive Ones"},"content":{"rendered":"<p>Given a binary array, find the maximum number of consecutive 1s in this array.<\/p>\n<p><b>Example 1:<\/b><\/p>\n<pre><b>Input:<\/b> [1,1,0,1,1,1]\r\n<b>Output:<\/b> 3\r\n<b>Explanation:<\/b> The first two digits or the last three digits are consecutive 1s.\r\n    The maximum number of consecutive 1s is 3.\r\n<\/pre>\n<p><b>Note:<\/b><\/p>\n<ul>\n<li>The input array will only contain\u00a0<code>0<\/code>\u00a0and\u00a0<code>1<\/code>.<\/li>\n<li>The length of input array is a positive integer and will not exceed 10,000<\/li>\n<\/ul>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def findMaxConsecutiveOnes(self, nums):\r\n        &quot;&quot;&quot;\r\n        :type nums: List[int]\r\n        :rtype: int\r\n        &quot;&quot;&quot;\r\n        maximum = 0\r\n        imum = 0\r\n        for i in nums:\r\n            if i == 1:\r\n                imum += 1\r\n                maximum = max(maximum, imum)\r\n            else:\r\n                imum = 0\r\n        return maximum\r\n        \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given a binary array, find the maximum number of consec<a href=\"https:\/\/www.ccagml.com\/?p=209\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">485. Max Consecutive Ones<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/209"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=209"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/209\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/209\/revisions\/210"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}