
sliding window
老晨磕技术
每天定时定量,持之以恒。一天一点数十年持续积累,坚持的人总不会混得太差。
展开
-
晨哥Leetcode 992. Subarrays with K Different Integers
Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that subarray is exactly K.(For example, [1,2,3,1,2] h...原创 2019-09-02 01:44:59 · 159 阅读 · 0 评论 -
晨哥Leetcode 424. Longest Repeating Character Replacement
Given a string s that consists of only uppercase English letters, you can perform at most k operations on that string.In one operation, you can choose any character of the string and change it to a...原创 2019-09-02 04:57:23 · 91 阅读 · 0 评论 -
晨哥Leetcode 239. Sliding Window Maximum
Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window...原创 2019-09-03 01:02:44 · 112 阅读 · 0 评论 -
晨哥Leetcode: sliding window滑动窗口套路
for循环用end指针一直向后,当窗口不再满足条件时,内部while循环解决start指针以下模板应背诵:1004. Max Consecutive Ones III int res = 0; int start = 0, count = 0; for(int end = 0; end< a.length; end++) {//end指针去...原创 2019-09-03 06:34:22 · 273 阅读 · 0 评论 -
晨哥Leetcode 1040. Moving Stones Until Consecutive II
https://leetcode.com/problems/moving-stones-until-consecutive-ii/Example 1:Input: [7,4,9]Output: [1,2]Explanation:We can move 4 -> 8 for one move to finish the game.Or, we can move 9 -> 5...原创 2019-09-03 07:03:14 · 596 阅读 · 0 评论 -
晨哥Leetcode 1074. Number of Submatrices That Sum to Target
Given a matrix, and a target, return the number of non-empty submatrices that sum to target.A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y &l...原创 2019-09-06 09:43:39 · 1101 阅读 · 0 评论 -
晨哥Leetcode 76. Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Example:Input: S = “ADOBECODEBANC”, T = “ABC”Output: “BANC”Note:If the...原创 2019-09-06 10:38:46 · 85 阅读 · 0 评论