Count Subarrays With Fixed Bounds
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given an integer array nums and two integers min_k and max_k. A contiguous subarray is **fixed-bound** when its minimum is exactly min_k and its maximum is exactly max_k.
Return the number of fixed-bound subarrays. Subarrays at different positions count separately even if their contents are equal. The count can exceed 32-bit range.
Aim for O(n) time and O(1) extra space.
Examples
Constraints
- 2 <= nums.length <= 10^5
- 1 <= nums[i], min_k, max_k <= 10^6
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.