Sliding Window Minimum
Sliding Window Minimum: Given an integer array nums and an integer k, a window of exactly k consecutive elements moves from left to right by one position at…
Given an integer array `nums` and an integer `k`, a window of exactly `k` consecutive elements moves from left to right by one position at a time. Return the minimum value in every window, in window order.
- `1 <= nums.length <= 10^5` - `-10^4 <= nums[i] <= 10^4` - `1 <= k <= nums.length` - The interactive visualizer accepts at most 12 values; longer valid inputs are execution-only.
Example 1: input nums = [1,3,-1,-3,5,3,6,7], k = 3; output [-1,-3,-3,-3,3,3]. Window by window: [1,3,-1] has minimum -1; [3,-1,-3] has minimum -3; [-1,-3,5] has minimum -3; [-3,5,3] has minimum -3; [5,3,6] has minimum 3; [3,6,7] has minimum 3. That gives [-1,-3,-3,-3,3,3].
Example 2: input nums = [1], k = 1; output [1].
Category: Sliding Window. Topic: sliding-window. Difficulty: Hard. Patterns: sliding-window, monotonic-stack.