
sliding window
ForABiggerWorld
这个作者很懒,什么都没留下…
展开
-
1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
Given anarray of integersnumsand anintegerlimit, return the size of the longest continuous subarray such that the absolute difference between any two elements is less than or equal tolimit.In ...原创 2020-05-05 22:28:01 · 480 阅读 · 0 评论 -
1234. Replace the Substring for Balanced String
You are given a string containing only 4kinds of characters'Q','W', 'E'and'R'.A string is said to bebalancedif each of its characters appearsn/4times wherenis the length of the string.R...原创 2019-10-20 14:29:30 · 752 阅读 · 0 评论 -
1208. Get Equal Substrings Within Budget
You are given two stringssandtof the same length. You want to changestot. Changing thei-th character ofstoi-th character oftcosts|s[i] - t[i]|that is, the absolute difference between th...原创 2019-10-07 16:11:36 · 209 阅读 · 0 评论 -
1052. Grumpy Bookstore Owner
Today, the bookstore owner has a store open forcustomers.lengthminutes. Every minute, some number of customers (customers[i]) enter the store, and all those customers leave after the end of that mi...原创 2019-05-26 12:00:06 · 489 阅读 · 0 评论 -
1040. Moving Stones Until Consecutive II
On aninfinitenumber line, the position of the i-th stone is given bystones[i]. Call a stone anendpoint stoneif it has the smallest or largest position.Each turn, you pick up an endpoint stone ...原创 2019-05-05 14:44:56 · 751 阅读 · 0 评论 -
1004. Max Consecutive Ones III
Given an arrayAof 0s and 1s, we may change up toKvalues 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,...原创 2019-03-03 12:39:51 · 159 阅读 · 0 评论 -
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] ha...原创 2019-02-10 15:00:39 · 918 阅读 · 0 评论 -
862. Shortest Subarray with Sum at Least K
Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K.If there is no non-empty subarray with sum at least K, return -1. Example 1:Input: A = [1], K = 1Output: 1E...原创 2018-07-01 12:08:07 · 695 阅读 · 0 评论 -
438. Find All Anagrams in a String
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be lar原创 2018-02-06 10:23:26 · 234 阅读 · 0 评论 -
30. Substring with Concatenation of All Words
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and原创 2017-09-04 20:29:50 · 239 阅读 · 0 评论