Skip to main content
239, Sliding Window Maximum

I Problem

You are given an array of integers 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 moves right by one position.


MikeAbout 3 minstack/queuehardarrayqueuesliding windowheadmonotonic queue
438, Find All Anagrams in a String

I Problem

Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.


MikeAbout 2 minhashtablemediumhash tablestringsliding window
76, Minimum Window Substring

I Problem

Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "".

The testcases will be generated such that the answer is unique.


MikeAbout 2 minarrayhardhash tablestringsliding window
904, Fruit Into Baskets

I Problem

You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the iᵗʰ tree produces.

You want to collect as much fruit as possible. However, the owner has some strict rules that you must follow:


MikeAbout 2 minarraymediumarrayhash tablesliding window
209, Minimum Size Subarray Sum

I Problem

Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead.

Example 1:
Input: target = 7, nums = [2,3,1,2,4,3]
Output: 2
Explanation: The subarray [4,3] has the minimal length under the problem constraint.


MikeAbout 2 minarraymediumarraybinary searchsliding windowprefix sum