<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Sequence DP on Jeanphilo Blog</title><link>https://shio-chan-dev.github.io/jeanblog/tags/sequence-dp/</link><description>Recent content in Sequence DP on Jeanphilo Blog</description><generator>Hugo -- 0.166.0</generator><language>en-us</language><lastBuildDate>Tue, 22 Sep 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://shio-chan-dev.github.io/jeanblog/tags/sequence-dp/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 300: Longest Increasing Subsequence, Deriving Sequence DP from Ending at i</title><link>https://shio-chan-dev.github.io/jeanblog/alg/leetcode/hot100/300-longest-increasing-subsequence/</link><pubDate>Tue, 22 Sep 2026 00:00:00 +0800</pubDate><guid>https://shio-chan-dev.github.io/jeanblog/alg/leetcode/hot100/300-longest-increasing-subsequence/</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;h3 id="input-and-output"&gt;Input and Output&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Input: an integer array &lt;code&gt;nums&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Output: return the length of the longest strictly increasing subsequence in &lt;code&gt;nums&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;A subsequence preserves the relative order of the original array, but it does not need to be contiguous, so elements may be skipped&lt;/li&gt;
&lt;li&gt;If the selected indices are &lt;code&gt;i_1 &amp;lt; i_2 &amp;lt; ... &amp;lt; i_k&lt;/code&gt;, they must also satisfy &lt;code&gt;nums[i_1] &amp;lt; nums[i_2] &amp;lt; ... &amp;lt; nums[i_k]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The subsequence is non-empty, so at least one element must be selected&lt;/li&gt;
&lt;li&gt;Constraints: &lt;code&gt;1 &amp;lt;= nums.length &amp;lt;= 2500&lt;/code&gt;, &lt;code&gt;-10^4 &amp;lt;= nums[i] &amp;lt;= 10^4&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="examples"&gt;Examples&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Input: nums = [10,9,2,5,3,7,101,18]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Output: 4
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Explanation: [2,5,7,101] is a strictly increasing subsequence of length 4; its elements do not need to be contiguous in the original array.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Input: nums = [0,1,0,3,2,3]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Output: 4
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Explanation: [0,1,2,3] has length 4; [0,1,3] is also valid, but shorter.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This article uses Python only. We start with the local question &amp;ldquo;how long can a subsequence ending at each position be?&amp;rdquo; and gradually turn it into a runnable solution.&lt;/p&gt;</description></item></channel></rss>