![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
滑动窗口
文章平均质量分 85
memcpy0
希望探索文理结合的自由之路。
展开
-
LeetCode 2134. 最少交换次数来组合所有的 1 II【滑动窗口】1748
元素。原创 2024-08-04 02:12:41 · 287 阅读 · 0 评论 -
LeetCode 1652. 拆炸弹【定长滑窗】简单
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2024-05-05 16:14:55 · 1095 阅读 · 0 评论 -
LeetCode 2090. K Radius Subarray Averages【前缀和,滑动窗口,数组】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-06-21 23:11:53 · 538 阅读 · 0 评论 -
LeetCode 1248. Count Number of Nice Subarrays【前缀和,哈希表;数学;滑动窗口】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-06-20 16:43:09 · 684 阅读 · 0 评论 -
LeetCode 1156. Swap For Longest Repeated Character Substring【滑动窗口,哈希表,双指针】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-06-05 15:22:28 · 712 阅读 · 0 评论 -
LeetCode 1040. Moving Stones Until Consecutive II【排序,滑动窗口,双指针】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的。原创 2023-04-08 10:30:38 · 186 阅读 · 0 评论 -
LeetCode 2379. Minimum Recolors to Get K Consecutive Black Blocks【字符串,前缀和,滑动窗口】简单
LeetCode题解原创 2023-03-11 17:54:51 · 98 阅读 · 0 评论 -
【PAT顶级】1026 String of Colorful Beads (35 分)【滑动窗口/哈希表】
Eva would like to buy a string of beads with no repeated colors so she went to a small shop of which the owner had a very long string of beads. However the owner would only like to cut one piece at a time for his customer. With as many as ten thousand bead原创 2021-05-22 19:18:08 · 149 阅读 · 0 评论 -
LeetCode C++ 1658. Minimum Operations to Reduce X to Zero【贪心/滑动窗口】中等
You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifies the array for future operations.Return the minim原创 2021-05-02 03:13:27 · 344 阅读 · 0 评论 -
LeetCode C++ 1004. Max Consecutive Ones III【Array/Sliding Window】中等
Given an array A of 0s and 1s, we may change up to K values from 0 to 1.Return the length of the longest (contiguous) subarray that contains only 1s. Example 1:Input: A = [1,1,1,0,0,0,1,1,1,1,0], K = 2Output: 6Explanation: [1,1,1,0,0,原创 2021-02-20 20:56:02 · 171 阅读 · 0 评论 -
LeetCode C++ 1423. Maximum Points You Can Obtain from Cards【Array/Sliding Window】中等
There are several cards arranged in a row, and each card has an associated number of points The points are given in the integer array cardPoints.In one step, you can take one card from the beginning or from the end of the row. You have to t原创 2021-02-17 23:28:39 · 186 阅读 · 0 评论 -
LeetCode C++ 1176. Diet Plan Performance【前缀和/滑动窗口】简单
A dieter consumes calories[i] calories on the i-th day. Given an integer k, for every consecutive sequence of k days (calories[i], calories[i+1], ..., calories[i+k-1] for all 0 <= i <= n-k), they look at T, the total calories con原创 2020-12-18 21:48:21 · 314 阅读 · 1 评论 -
LeetCode C++ 594. Longest Harmonious Subsequence【HashTable/Sort/Two Pointers/Sliding Window】简单
We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1 .Given an integer array nums, return the length of its longest harmonious subsequence among all its possible subsequences.A subsequ原创 2020-11-10 20:45:27 · 145 阅读 · 0 评论 -
LeetCode C++ 643. Maximum Average Subarray I【Array/Sliding Window】简单
Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.Example 1:Input: [1,12,-5,-6,50,3], k = 4Output: 12.75Explanation: Maximum aver原创 2020-11-10 15:50:37 · 147 阅读 · 0 评论 -
LeetCode C++ 485. Max Consecutive Ones【Array/Sliding Window】简单
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.Note:T原创 2020-11-05 01:18:18 · 178 阅读 · 0 评论 -
LeetCode C++ 209. Minimum Size Subarray Sum【二分/滑窗/双指针】中等
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead.Example:Input: s = 7, nums = [2,3,1,2,4,3]Output: 2Explanation: the subarray [4,原创 2020-06-27 16:08:27 · 218 阅读 · 0 评论 -
LeetCode C++ 3. Longest Substring Without Repeating Characters【滑动窗口】中等
文章目录原创 2020-06-04 21:52:16 · 189 阅读 · 0 评论