Deque and window maximum: Given nums and a positive window size k, return the maximum value in every contiguous window of length k. Return an empty array when k is invalid.
Input: A JSON object { "nums": number[], "k": number }.
Output: A JSON number[] containing one maximum per complete window.
Constraints:
- 0 <= nums.length <= 100000
- k is an integer
- The expected solution is linear in nums.length
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: MEDIUM. Variant: 20. Expect follow-up questions about complexity, edge cases, and alternative approaches.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked medium difficulty.
The signed-in workspace provides the tools required by the r