<?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>Sliding-Window on Yu-Cheng's Notes</title><link>https://linkingmon.github.io/blog/tags/sliding-window/</link><description>Recent content in Sliding-Window on Yu-Cheng's Notes</description><generator>Hugo -- 0.166.0</generator><language>en-us</language><lastBuildDate>Mon, 02 Feb 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://linkingmon.github.io/blog/tags/sliding-window/index.xml" rel="self" type="application/rss+xml"/><item><title>LC 3013 - Divide an Array Into Subarrays With Minimum Cost II</title><link>https://linkingmon.github.io/blog/coding/lc-3013/</link><pubDate>Mon, 02 Feb 2026 00:00:00 +0000</pubDate><guid>https://linkingmon.github.io/blog/coding/lc-3013/</guid><description>&lt;h2 id="approach"&gt;Approach&lt;/h2&gt;
&lt;p&gt;Given a solution &lt;code&gt;[ group A ] [i1 .. ] .. [ .. ] [i(k-1)]&lt;/code&gt;, the distance between &lt;code&gt;i1&lt;/code&gt; and i(k-1)&lt;code&gt;should be smaller then dist, and we assume that now the group A is fixed. The problem now is that we need to find&lt;/code&gt;k-2&lt;code&gt;minimum elements in the range&lt;/code&gt;[i1 .. i(k-1)]&lt;code&gt;(excluding&lt;/code&gt;i1` itself), this part is similar to previous daily.&lt;/p&gt;
&lt;p&gt;Now we tried to do a sliding window, and we the current score is the first element of group A, plus the first element within the sliding window (&lt;code&gt;dist+1&lt;/code&gt; wide), and the sum of &lt;code&gt;k-2&lt;/code&gt; minimum value inside that sliding window (exlude the first one). We maintain the best score and we get the answer after sliding window.&lt;/p&gt;</description></item></channel></rss>