method
Sliding Window — animated LeetCode walkthroughs
LeetCode problems solved with Sliding Window. Browse the complete tag, then watch the algorithm move — step-by-step animation, Python and Go.
172 problems · 147 animated · 25 locked
Start with a walkthrough
Full Window index
- 3Longest Substring Without Repeating CharactersWatch
- 30Substring with Concatenation of All WordsWatch
- 76Minimum Window SubstringWatch
- 159Longest Substring with At Most Two Distinct CharactersLocked
- 187Repeated DNA SequencesWatch
- 209Minimum Size Subarray SumWatch
- 219Contains Duplicate IIWatch
- 220Contains Duplicate IIIWatch
- 239Sliding Window MaximumWatch
- 340Longest Substring with At Most K Distinct CharactersLocked
- 395Longest Substring with At Least K Repeating CharactersWatch
- 413Arithmetic SlicesWatch
- 424Longest Repeating Character ReplacementWatch
- 438Find All Anagrams in a StringWatch
- 480Sliding Window MedianWatch
- 487Max Consecutive Ones IILocked
- 567Permutation in StringWatch
- 594Longest Harmonious SubsequenceWatch
- 632Smallest Range Covering Elements from K ListsWatch
- 643Maximum Average Subarray IWatch
- 658Find K Closest ElementsWatch
- 683K Empty SlotsLocked
- 689Maximum Sum of 3 Non-Overlapping SubarraysWatch
- 713Subarray Product Less Than KWatch
- 718Maximum Length of Repeated SubarrayWatch
- 727Minimum Window SubsequenceLocked
- 837New 21 GameWatch
- 862Shortest Subarray with Sum at Least KWatch
- 904Fruit Into BasketsWatch
- 930Binary Subarrays With SumWatch
- 978Longest Turbulent SubarrayWatch
- 992Subarrays with K Different IntegersWatch
- 995Minimum Number of K Consecutive Bit FlipsWatch
- 1004Max Consecutive Ones IIIWatch
- 1016Binary String With Substrings Representing 1 To NWatch
- 1031Maximum Sum of Two Non-Overlapping SubarraysWatch
- 1040Moving Stones Until Consecutive IIWatch
- 1044Longest Duplicate SubstringWatch
- 1052Grumpy Bookstore OwnerWatch
- 1100Find K-Length Substrings With No Repeated CharactersLocked
- 1151Minimum Swaps to Group All 1's TogetherLocked
- 1156Swap For Longest Repeated Character SubstringWatch
- 1176Diet Plan PerformanceLocked
- 1208Get Equal Substrings Within BudgetWatch
- 1234Replace the Substring for Balanced StringWatch
- 1248Count Number of Nice SubarraysWatch
- 1297Maximum Number of Occurrences of a SubstringWatch
- 1343Number of Sub-arrays of Size K and Average Greater than or Equal to ThresholdWatch
- 1358Number of Substrings Containing All Three CharactersWatch
- 1423Maximum Points You Can Obtain from CardsWatch
- 1425Constrained Subsequence SumWatch
- 1438Longest Continuous Subarray With Absolute Diff Less Than or Equal to LimitWatch
- 1456Maximum Number of Vowels in a Substring of Given LengthWatch
- 1477Find Two Non-overlapping Sub-arrays Each With Target SumWatch
- 1493Longest Subarray of 1's After Deleting One ElementWatch
- 1499Max Value of EquationWatch
- 1610Maximum Number of Visible PointsWatch
- 1652Defuse the BombWatch
- 1658Minimum Operations to Reduce X to ZeroWatch
- 1695Maximum Erasure ValueWatch
- 1703Minimum Adjacent Swaps for K Consecutive OnesWatch
- 1763Longest Nice SubstringWatch
- 1838Frequency of the Most Frequent ElementWatch
- 1839Longest Substring Of All Vowels in OrderWatch
- 1852Distinct Numbers in Each SubarrayLocked
- 1871Jump Game VIIWatch
- 1876Substrings of Size Three with Distinct CharactersWatch
- 1888Minimum Number of Flips to Make the Binary String AlternatingWatch
- 1918Kth Smallest Subarray SumLocked
- 1956Minimum Time For K Virus Variants to SpreadLocked
- 1984Minimum Difference Between Highest and Lowest of K ScoresWatch
- 2009Minimum Number of Operations to Make Array ContinuousWatch
- 2024Maximize the Confusion of an ExamWatch
- 2067Number of Equal Count SubstringsLocked
- 2090K Radius Subarray AveragesWatch
- 2106Maximum Fruits Harvested After at Most K StepsWatch
- 2107Number of Unique Flavors After Sharing K CandiesLocked
- 2110Number of Smooth Descent Periods of a StockWatch
- 2134Minimum Swaps to Group All 1's Together IIWatch
- 2156Find Substring With Given Hash ValueWatch
- 2260Minimum Consecutive Cards to Pick UpWatch
- 2269Find the K-Beauty of a NumberWatch
- 2271Maximum White Tiles Covered by a CarpetWatch
- 2302Count Subarrays With Score Less Than KWatch
- 2379Minimum Recolors to Get K Consecutive Black BlocksWatch
- 2398Maximum Number of Robots Within BudgetWatch
- 2401Longest Nice SubarrayWatch
- 2411Smallest Subarrays With Maximum Bitwise ORWatch
- 2444Count Subarrays With Fixed BoundsWatch
- 2461Maximum Sum of Distinct Subarrays With Length KWatch
- 2516Take K of Each Character From Left and RightWatch
- 2524Maximum Frequency Score of a SubarrayLocked
- 2528Maximize the Minimum Powered CityWatch
- 2537Count the Number of Good SubarraysWatch
- 2555Maximize Win From Two SegmentsWatch
- 2653Sliding Subarray BeautyWatch
- 2730Find the Longest Semi-Repetitive SubstringWatch
- 2743Count Substrings Without Repeating CharacterLocked
- 2747Count Zero Request ServersWatch
- 2760Longest Even Odd Subarray With ThresholdWatch
- 2762Continuous SubarraysWatch
- 2779Maximum Beauty of an Array After Applying OperationWatch
- 2781Length of the Longest Valid SubstringWatch
- 2799Count Complete Subarrays in an ArrayWatch
- 2831Find the Longest Equal SubarrayWatch
- 2841Maximum Sum of Almost Unique SubarrayWatch
- 2875Minimum Size Subarray in Infinite ArrayWatch
- 2902Count of Sub-Multisets With Bounded SumWatch
- 2904Shortest and Lexicographically Smallest Beautiful StringWatch
- 2932Maximum Strong Pair XOR IWatch
- 2935Maximum Strong Pair XOR IIWatch
- 2953Count Complete SubstringsWatch
- 2958Length of Longest Subarray With at Most K FrequencyWatch
- 2962Count Subarrays Where Max Element Appears at Least K TimesWatch
- 2968Apply Operations to Maximize Frequency ScoreWatch
- 2981Find Longest Special Substring That Occurs Thrice IWatch
- 2982Find Longest Special Substring That Occurs Thrice IIWatch
- 3013Divide an Array Into Subarrays With Minimum Cost IIWatch
- 3023Find Pattern in Infinite Stream ILocked
- 3037Find Pattern in Infinite Stream IILocked
- 3086Minimum Moves to Pick K OnesWatch
- 3090Maximum Length Substring With Two OccurrencesWatch
- 3095Shortest Subarray With OR at Least K IWatch
- 3097Shortest Subarray With OR at Least K IIWatch
- 3134Find the Median of the Uniqueness ArrayWatch
- 3135Equalize Strings by Adding or Removing Characters at EndsLocked
- 3191Minimum Operations to Make Binary Array Elements Equal to One IWatch
- 3206Alternating Groups IWatch
- 3208Alternating Groups IIWatch
- 3254Find the Power of K-Size Subarrays IWatch
- 3255Find the Power of K-Size Subarrays IIWatch
- 3258Count Substrings That Satisfy K-Constraint IWatch
- 3261Count Substrings That Satisfy K-Constraint IIWatch
- 3297Count Substrings That Can Be Rearranged to Contain a String IWatch
- 3298Count Substrings That Can Be Rearranged to Contain a String IIWatch
- 3305Count of Substrings Containing Every Vowel and K Consonants IWatch
- 3306Count of Substrings Containing Every Vowel and K Consonants IIWatch
- 3318Find X-Sum of All K-Long Subarrays IWatch
- 3321Find X-Sum of All K-Long Subarrays IIWatch
- 3323Minimize Connected Groups by Inserting IntervalLocked
- 3325Count Substrings With K-Frequency Characters IWatch
- 3329Count Substrings With K-Frequency Characters IILocked
- 3346Maximum Frequency of an Element After Performing Operations IWatch
- 3347Maximum Frequency of an Element After Performing Operations IIWatch
- 3364Minimum Positive Sum Subarray Watch
- 3411Maximum Subarray With Equal ProductsWatch
- 3413Maximum Coins From K Consecutive BagsWatch
- 3420Count Non-Decreasing Subarrays After K OperationsWatch
- 3422Minimum Operations to Make Subarray Elements EqualLocked
- 3439Reschedule Meetings for Maximum Free Time IWatch
- 3445Maximum Difference Between Even and Odd Frequency IIWatch
- 3505Minimum Operations to Make Elements Within K Subarrays EqualWatch
- 3578Count Partitions With Max-Min Difference at Most KWatch
- 3589Count Prime-Gap Balanced SubarraysWatch
- 3634Minimum Removals to Balance ArrayWatch
- 3641Longest Semi-Repeating SubarrayLocked
- 3652Best Time to Buy and Sell Stock using StrategyWatch
- 3672Sum of Weighted Modes in SubarraysLocked
- 3679 Minimum Discards to Balance InventoryWatch
- 3694Distinct Points Reachable After Substring RemovalWatch
- 3768Minimum Inversion Count in Subarrays of Fixed LengthWatch
- 3795Minimum Subarray Length With Distinct Sum At Least KWatch
- 3845Maximum Subarray XOR with Bounded RangeWatch
- 3851Maximum Requests Without Violating the LimitLocked
- 3859Count Subarrays With K Distinct IntegersWatch
- 3956Maximum Sum of M Non-Overlapping Subarrays IWatch
- 3957Maximum Sum of M Non-Overlapping Subarrays IIWatch
- 3969Valid Subarrays With Matching Sum Digits IWatch
- 3972Valid Subarrays With Matching Sum Digits IILocked
- 4032Longest Subarray With at Most K Distinct Prime FactorsWatch
- 4043Count Rotations With Exactly K Equal Adjacent PairsWatch
- 4044Count Good Cyclic RotationsWatch