{"id":199,"date":"2017-09-10T08:24:29","date_gmt":"2017-09-10T15:24:29","guid":{"rendered":"http:\/\/zxi.mytechroad.com\/blog\/?p=199"},"modified":"2018-07-10T18:32:09","modified_gmt":"2018-07-11T01:32:09","slug":"leetcode-674-longest-continuous-increasing-subsequence","status":"publish","type":"post","link":"https:\/\/zxi.mytechroad.com\/blog\/dynamic-programming\/leetcode-674-longest-continuous-increasing-subsequence\/","title":{"rendered":"\u82b1\u82b1\u9171 LeetCode 674. Longest Continuous Increasing Subsequence"},"content":{"rendered":"<p><iframe loading=\"lazy\" title=\"\u82b1\u82b1\u9171 LeetCode 674. Longest Continuous Increasing Subsequence - \u5237\u9898\u627e\u5de5\u4f5c EP47\" width=\"500\" height=\"375\" src=\"https:\/\/www.youtube.com\/embed\/I_bxq4nm2sk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p><strong>Problem:<\/strong><\/p>\n<div class=\"question-description\">\n<p>Given an unsorted array of integers, find the length of longest\u00a0<code>continuous<\/code>\u00a0increasing subsequence.<\/p>\n<p><b>Example 1:<\/b><\/p>\n<pre class=\"\">Input: [1,3,5,4,7]\r\nOutput: 3\r\n<\/pre>\n<p>Explanation: The longest continuous increasing subsequence is [1,3,5], its length is 3. Even though [1,3,5,7] is also an increasing subsequence, it&#8217;s not a continuous one where 5 and 7 are separated by 4.<\/p>\n<p><b>Example 2:<\/b><\/p>\n<pre class=\"\">Input: [2,2,2,2,2]\r\nOutput: 1\r\n<\/pre>\n<p>Explanation: The longest continuous increasing subsequence is [2], its length is 1.<\/p>\n<p><b>Note:<\/b>\u00a0Length of the array will not exceed 10,000.<\/p>\n<\/div>\n<div id=\"interviewed-div\"><strong>Idea:<\/strong><\/div>\n<div><\/div>\n<div>Dynamic Programming<\/div>\n<div><\/div>\n<div><\/div>\n<div><a href=\"http:\/\/zxi.mytechroad.com\/blog\/wp-content\/uploads\/2017\/09\/674-ep47.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-200\" src=\"http:\/\/zxi.mytechroad.com\/blog\/wp-content\/uploads\/2017\/09\/674-ep47.png\" alt=\"\" width=\"960\" height=\"540\" srcset=\"https:\/\/zxi.mytechroad.com\/blog\/wp-content\/uploads\/2017\/09\/674-ep47.png 960w, https:\/\/zxi.mytechroad.com\/blog\/wp-content\/uploads\/2017\/09\/674-ep47-300x169.png 300w, https:\/\/zxi.mytechroad.com\/blog\/wp-content\/uploads\/2017\/09\/674-ep47-768x432.png 768w, https:\/\/zxi.mytechroad.com\/blog\/wp-content\/uploads\/2017\/09\/674-ep47-624x351.png 624w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><\/div>\n<div><\/div>\n<div><strong>Solution:<\/strong><\/div>\n<div>\n<pre class=\"lang:c++ decode:true  \">\/\/ Author: Huahua\r\nclass Solution {\r\npublic:\r\n    int findLengthOfLCIS(vector&lt;int&gt;&amp; nums) {\r\n        if (nums.empty()) return 0;\r\n        int cur = 1;\r\n        int ans = 1;\r\n        for (int i = 1; i &lt; nums.size(); ++i) {\r\n            if (nums[i] &gt; nums[i-1]) {\r\n                ++cur;\r\n                ans = max(ans, cur);\r\n            } else {\r\n                cur = 1;\r\n            }            \r\n        }\r\n        return ans;\r\n    }\r\n};<\/pre>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Problem: Given an unsorted array of integers, find the length of longest\u00a0continuous\u00a0increasing subsequence. Example 1: Input: [1,3,5,4,7] Output: 3 Explanation: The longest continuous increasing subsequence&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[67,68,66],"class_list":["post-199","post","type-post","status-publish","format-standard","hentry","category-dynamic-programming","tag-lc","tag-lcis","tag-lcs","entry","simple"],"_links":{"self":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/comments?post=199"}],"version-history":[{"count":6,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/199\/revisions"}],"predecessor-version":[{"id":3061,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/199\/revisions\/3061"}],"wp:attachment":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/media?parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/categories?post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/tags?post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}