<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.ta.in.th/index.php?action=history&amp;feed=atom&amp;title=Sliding_Window_Minimum</id>
	<title>Sliding Window Minimum - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ta.in.th/index.php?action=history&amp;feed=atom&amp;title=Sliding_Window_Minimum"/>
	<link rel="alternate" type="text/html" href="https://wiki.ta.in.th/index.php?title=Sliding_Window_Minimum&amp;action=history"/>
	<updated>2026-06-16T22:57:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0-alpha</generator>
	<entry>
		<id>https://wiki.ta.in.th/index.php?title=Sliding_Window_Minimum&amp;diff=93&amp;oldid=prev</id>
		<title>Tata: Created page with &quot;== Problem ==   for (i = 0; i &lt; ARR.size(); i++) {    remove ARR[i-K] from the sliding window    insert ARR[i] into the sliding window    output the smallest value in the wind...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.ta.in.th/index.php?title=Sliding_Window_Minimum&amp;diff=93&amp;oldid=prev"/>
		<updated>2019-03-07T17:13:45Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Problem ==   for (i = 0; i &amp;lt; ARR.size(); i++) {    remove ARR[i-K] from the sliding window    insert ARR[i] into the sliding window    output the smallest value in the wind...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Problem ==&lt;br /&gt;
&lt;br /&gt;
 for (i = 0; i &amp;lt; ARR.size(); i++) {&lt;br /&gt;
   remove ARR[i-K] from the sliding window&lt;br /&gt;
   insert ARR[i] into the sliding window&lt;br /&gt;
   output the smallest value in the window&lt;br /&gt;
 }&lt;br /&gt;
* ให้หา min(ARR[i] , ARR[i+1] , ARR[i+2] , ... , ARR[i+K-1])&lt;br /&gt;
* หรือ ถ้าอธิบายเป็นภาษาคนก็ คือ มีเลขอยู่ N ตัว ให้หาค่าน้อยที่สุด (min) ของตัวเลข K ตัวที่ติดกัน เช่น มีเลข 8 เลข ต้องการหาค่าน้อยสุดของเลข 3 ตัวที่อยู่ติดกัน (N=8, K=3)&lt;br /&gt;
* เช่น ARR = {1,2,5,8,6,2,4}  ,  N=7  ,  K=3  ,  จะได้  เซตค่าน้อยสุดคิดเป็นช่วง 3 ตัวติดกัน = {1,1,1,2,5,2,2}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
* Naive Algorithms : '''O(NK)''' วิธีทื่อๆ&lt;br /&gt;
* Naive Algorithms : '''O(N log K)''' ถ้าใช้ heap มาช่วย&lt;br /&gt;
* Sliding Window Minimum : '''O(N)'''   (ถ้าคิด Amortized O(1) per insertion/deletion  กรณีใช้ Deque เข้ามาช่วย)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sliding Window Minimum : O(N) ==&lt;br /&gt;
ไว้ว่างๆจะมาแปลต่อ = =&amp;quot;&lt;br /&gt;
http://people.cs.uct.ac.za/~ksmith/articles/sliding_window_minimum.html&lt;br /&gt;
&lt;br /&gt;
== 2D-Array | Sliding Window Minimum : O(N^2) ==&lt;br /&gt;
วิธีแม่งโคตร เมพ  บร๊ะเจ้าช่วย  กล้วยทอด  คนคิดช่างประเสริฐ โดยสัญชาติญาณ แท้ๆๆ เทียว ที เดียว เชียว&lt;br /&gt;
http://stackoverflow.com/questions/10732841/sliding-window-minimum-maximum-in-2d&lt;/div&gt;</summary>
		<author><name>Tata</name></author>
		
	</entry>
</feed>