Sliding window
ZustinLau
I am currently studying Economics at the Chinese University of Hong Kong and I am interested in data structure and algorithms.
展开
-
1493. Longest Subarray of 1‘s After Deleting One Element(DP/sliding window)
Pretty straightforward!We use sliding window and when the 0 appears in that window more than once, we would break the window, otherwise we would keep update the answer.class Solution {public: int longestSubarray(vector<int>& nums) {原创 2022-05-28 02:28:52 · 53 阅读 · 0 评论 -
1031. Maximum Sum of Two Non-Overlapping Subarrays(sliding window + DP)
This is an implicit sliding window problem. It is almost the same as buying and selling the stock 3.The idea is that we gonna set up a middle line, and the line would keep moving forward. When is it moving, we would see if there is any better option for原创 2022-05-28 00:59:22 · 69 阅读 · 0 评论 -
53. Maximum Subarray (sliding window)
We know the subarray is a consecutive part of an array and this leads us to think about the two-pointer and sliding windows sort of algorithms.As the question asks to find the maximum sum of the subarray. We consider using sliding windows which is a powe原创 2022-05-11 04:28:46 · 82 阅读 · 0 评论