<?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>Biweek-173 on Yu-Cheng's Notes</title><link>https://linkingmon.github.io/blog/tags/biweek-173/</link><description>Recent content in Biweek-173 on Yu-Cheng's Notes</description><generator>Hugo -- 0.166.0</generator><language>en-us</language><lastBuildDate>Sat, 03 Jan 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://linkingmon.github.io/blog/tags/biweek-173/index.xml" rel="self" type="application/rss+xml"/><item><title>LC 3797 - Count Routes to Climb a Rectangular Grid</title><link>https://linkingmon.github.io/blog/coding/lc-3797/</link><pubDate>Sat, 03 Jan 2026 00:00:00 +0000</pubDate><guid>https://linkingmon.github.io/blog/coding/lc-3797/</guid><description>&lt;h2 id="approach"&gt;Approach&lt;/h2&gt;
&lt;p&gt;This is a DP like problem, and I find that we can think that when we want to calculate &lt;code&gt;ans[i][j]&lt;/code&gt; on row &lt;code&gt;i&lt;/code&gt; from row &lt;code&gt;i-1&lt;/code&gt;, we just aggregate the previous row&amp;rsquo;s &lt;code&gt;ans&lt;/code&gt; within the l2 distance of &lt;code&gt;d&lt;/code&gt; and we get the answer.&lt;/p&gt;
&lt;p&gt;But the problem stats that we can jump in the same row in range &lt;code&gt;d&lt;/code&gt;, so I tried to buffer the row &lt;code&gt;i-1&lt;/code&gt; aggregated results to &lt;code&gt;jump&lt;/code&gt;, and then try to sum up all the &lt;code&gt;jump&lt;/code&gt; within distance &lt;code&gt;d&lt;/code&gt;.
Originally I think that for the index &lt;code&gt;j&lt;/code&gt; itself we need to count twice, since we can jump from upper row, or jump from upper row and jump to itself again. However, from the testcase it seems that jump to itself is invalid. Under this circumstance we just add up all the jumps within range &lt;code&gt;d&lt;/code&gt; and we got the answer for row &lt;code&gt;i&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>LC 3796 - Find Maximum Value in a Constrained Sequence</title><link>https://linkingmon.github.io/blog/coding/lc-3796/</link><pubDate>Sat, 03 Jan 2026 00:00:00 +0000</pubDate><guid>https://linkingmon.github.io/blog/coding/lc-3796/</guid><description>&lt;h2 id="approach"&gt;Approach&lt;/h2&gt;
&lt;p&gt;This seems like there is a greedy approach.
I think that we can represent by a range.
If index &lt;code&gt;i&lt;/code&gt; is constraint to be smaller than 2, its range is [0, 2].
And if its difference to the next point is smaller than 3, the range for next point is [-3, 5], and we can keep propagate to the right side.
Later I found that the number would be positive, so actually we don&amp;rsquo;t need to care about the negative part, just calculate the largest part.&lt;/p&gt;</description></item><item><title>LC 3795 - Minimum Subarray Length With Distinct Sum At Least K</title><link>https://linkingmon.github.io/blog/coding/lc-3795/</link><pubDate>Sat, 03 Jan 2026 00:00:00 +0000</pubDate><guid>https://linkingmon.github.io/blog/coding/lc-3795/</guid><description>&lt;h2 id="approach"&gt;Approach&lt;/h2&gt;
&lt;p&gt;This is quite easy to see that is a two pointer type of problem.&lt;/p&gt;
&lt;p&gt;One difficult part is that for the boundary condition, such as one elemenet only may need some carefull handling (I get WA on that).&lt;/p&gt;
&lt;p&gt;Also, the sum should remove duplicates so we need to store the count for each variable with a hashmap.
Add when there is no this element in the range yet, and remove if this is the last one in the range! (also get 1 WA on this&amp;hellip;)&lt;/p&gt;</description></item><item><title>LC 3794 - Reverse String Prefix</title><link>https://linkingmon.github.io/blog/coding/lc-3794/</link><pubDate>Sat, 03 Jan 2026 00:00:00 +0000</pubDate><guid>https://linkingmon.github.io/blog/coding/lc-3794/</guid><description>&lt;h2 id="approach"&gt;Approach&lt;/h2&gt;
&lt;p&gt;This is really simple, just use the &lt;code&gt;reverse()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;Time complexity is &lt;code&gt;O(N)&lt;/code&gt;, and no extra space complexity.&lt;/p&gt;
&lt;h2 id="code"&gt;Code&lt;/h2&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-c++" data-lang="c++"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Solution&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;public&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; string reversePrefix(string s, &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt; k) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; reverse(s.begin(), s.begin()&lt;span style="color:#f92672"&gt;+&lt;/span&gt;k);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; s;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;};
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item></channel></rss>