Ezvor

3555. Smallest Subarray to Sort in Every Sliding Window

MediumArray Preparing judge… LeetCode
ArrayTwo PointersStackGreedySortingMonotonic Stack

Hints

Hint 1
Solve for each subarray independently.
Hint 2
What are the extreme positions that need to be included in the segment to make the subarray non‑decreasing?