leetcode-907 - Sum of Subarray Minimums

動機 之前有一題就是用左右兩邊的長度相乘算組合數,不過這題還要快速求出左右兩邊,所以就用了monotone stack monotone stack有兩個用途 previous less element next less element 詳細看這篇 ...

August 16, 2021 · 2 min · zhengcf

leetcode-718 - Maximum Length of Repeated Subarray

動機 超有意思的題目,只能用bottomup dp的題目!! 下次不能說topdown與bottomup的dp可以互換了 topdown dp與bottomup dp差在一個在前半段處理,另一個在後半段 因為上面的特質導致這題只能用bottomup ...

August 16, 2021 · 1 min · zhengcf

leetcode-1438 - Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit

動機 sliding window但是用heap去找window的最大最小 ...

August 16, 2021 · 2 min · zhengcf

leetcode-1248 - Count Number of Nice Subarrays

動機 atMost或是在回收時計算長度 ...

August 15, 2021 · 1 min · zhengcf

leetcode-930 - Binary Subarrays With Sum

動機 用atMost秒殺 用prefix sum in fly也可以 ...

August 15, 2021 · 1 min · zhengcf

leetcode-1004 - Max Consecutive Ones III

動機 基本款sliding window ...

August 15, 2021 · 1 min · zhengcf

leetcode-992 - Subarrays with K Different Integers

動機 sliding window的新招式 binary search的range是左閉右開 lower bound: >=的第一個值 upper bound: >的第一個值 sliding window是左閉右閉 atMost: <=目標的所有區間總數 ...

August 15, 2021 · 1 min · zhengcf

leetcode-546 - Remove Boxes

動機 三維dp!? 這真的能在45分做出來? ...

August 15, 2021 · 1 min · zhengcf

leetcode-862 - Shortest Subarray with Sum at Least K

動機 What makes this problem hard is that we have negative values. sliding window + monotone stack = monotone queue prefix sum in fly + hash ...

August 15, 2021 · 1 min · zhengcf

leetcode-399 - Evaluate Division

動機 建圖去走 ...

August 14, 2021 · 2 min · zhengcf