<?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>Week-483 on Yu-Cheng's Notes</title><link>https://linkingmon.github.io/blog/tags/week-483/</link><description>Recent content in Week-483 on Yu-Cheng's Notes</description><generator>Hugo -- 0.166.0</generator><language>en-us</language><lastBuildDate>Sun, 04 Jan 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://linkingmon.github.io/blog/tags/week-483/index.xml" rel="self" type="application/rss+xml"/><item><title>LC 3800 - Minimum Cost to Make Two Binary Strings Equal</title><link>https://linkingmon.github.io/blog/coding/lc-3800/</link><pubDate>Sun, 04 Jan 2026 00:00:00 +0000</pubDate><guid>https://linkingmon.github.io/blog/coding/lc-3800/</guid><description>&lt;h2 id="approach"&gt;Approach&lt;/h2&gt;
&lt;p&gt;This seems to be a greedy like problem, and I tried to walk the algorithm by-hand.&lt;/p&gt;
&lt;p&gt;For a simple case, cross and swap operations can be done by two flips.
Therefore, if the cost for cross or swap is larger than two flips, we simply replace it with two flips cost.&lt;/p&gt;
&lt;p&gt;Then, we check when we need to use swap operation.
Let&amp;rsquo;s say we have two sequence as follows
&lt;code&gt;s = 1 .. 0&lt;/code&gt;
&lt;code&gt;t = 0 .. 1&lt;/code&gt;
If we want to eliminate the first difference by swapping, we need to find another (0, 1) pair to swap, since swapping with (0, 0) and (1, 1) did not change anything, this is just moving the difference backwards.
So the greedy method is that we eliminate all the (1, 0) and (0, 1) pairs by swapping.&lt;/p&gt;</description></item><item><title>LC 3799 - Word Squares II</title><link>https://linkingmon.github.io/blog/coding/lc-3799/</link><pubDate>Sun, 04 Jan 2026 00:00:00 +0000</pubDate><guid>https://linkingmon.github.io/blog/coding/lc-3799/</guid><description>&lt;h2 id="approach"&gt;Approach&lt;/h2&gt;
&lt;p&gt;This is like a backtracking problem, and we find that the size of the &lt;code&gt;words&lt;/code&gt; is not large, so this should be the solution.&lt;/p&gt;
&lt;p&gt;We simply just try all the permutations in &lt;code&gt;words[idx:end]&lt;/code&gt; (handling in &lt;code&gt;traverse()&lt;/code&gt; function).
This is done by swapping &lt;code&gt;idx&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt; (from &lt;code&gt;idx&lt;/code&gt; to &lt;code&gt;end&lt;/code&gt;), and then call &lt;code&gt;traverse()&lt;/code&gt; recursively.
We can swap the &lt;code&gt;idx&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt; back after the recursive call, in this case we can reuse the &lt;code&gt;words&lt;/code&gt; order, and don’t need extra cache for the original &lt;code&gt;words&lt;/code&gt; value (this method is commonly used in a backtracking problem).&lt;/p&gt;</description></item><item><title>LC 3798 - Largest Even Number</title><link>https://linkingmon.github.io/blog/coding/lc-3798/</link><pubDate>Sun, 04 Jan 2026 00:00:00 +0000</pubDate><guid>https://linkingmon.github.io/blog/coding/lc-3798/</guid><description>&lt;h2 id="approach"&gt;Approach&lt;/h2&gt;
&lt;p&gt;We just simply check the last char to see if it is 0,2,4,6,8.
We remove the character if it is not one of them, the final string then would be the answer.&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 largestEven(string s) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;while&lt;/span&gt;(s.size() &lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;((s[s.size()&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;] &lt;span style="color:#f92672"&gt;-&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;0&amp;#39;&lt;/span&gt;) &lt;span style="color:#f92672"&gt;%&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;) &lt;span style="color:#66d9ef"&gt;break&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; s.pop_back();
&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 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>