← 返回 bytedance 的题目列表Sliding Window Maximum
类型:qbank
The unmodified LeetCode 239 prompt: given an integer array and a fixed window size, return the maximum value in every window as it advances one position at a time.
Requirements
Given an integer array nums and a window size k, consider every contiguous subarray of length k.
Move the window one position to the right at each step.
Return the maximum value from each window in left-to-right order.
Examples
Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
Output: [3,3,5,5,6,7]
Notes
The prompt was the unmodified LC 239 problem.
The first round opened with a resume discussion and a question about LLM applications. About 15 minutes of collaborative coding was enough to establish the implementation framework.
Preparation
Implement both the direct per-window scan and the linear-time version, then explain the invariant maintained by the candidate set.
Drill duplicate values, negative values, k = 1, and k = len(nums) without relying on an IDE.