Sliding Window At Most Problem
These problems are sliding windows but solve by 2 passes
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]
has 3
different integers: 1
, 2
, and 3
.)
Return the number of good subarrays of A
930. Binary Subarrays with Sum
In an array A
of 0
s and 1
s, how many non-empty subarrays have sum S
?
1248. Count Number of Nice Subarrays
Given an array of integers nums
and an integer k
. A subarray is called nice if there are k
odd numbers on it.
Return the number of nice sub-arrays.
Last updated
Was this helpful?