Not sure what to study next?

Get a personalised quant interview roadmap built around your upcoming interviews, strengths and weaknesses.

Takes a few minutes. Start with your target role and firms.

← Programming questions
Hard / PYTHON

Rolling Price Minimum and Maximum

deques · sliding_window · streaming · time_series 38 minute study target

Not completed

Challenge

For every complete consecutive window of exactly width observations, return [minimum_price, maximum_price]. Output windows from oldest to newest. Unlike the time-window-average exercise, width counts observations, not elapsed time. Return [] when fewer than width prices exist.

Input and output contract

0 ≤ n ≤ 50,000; positive integer width ≤ 60,000; integer prices 0..1,000,000. Test inputs have at most 2,000 complete windows, so max(0,n-width+1)≤2,000; this bounds result size. Duplicates remain valid observations.

All tests follow this contract. You do not need to validate malformed input. Return the requested result from rolling_price_window; printed output is not your answer. Standard-library tools are allowed. Implement your solution in Python 3.12.

Target complexity: O(n) time; O(min(n, width)) auxiliary space plus output

Return values are checked by type. Use the exact function name. Print output is not your answer. Tests have time and memory limits.

Public examples

Example 1

Arguments

[[4, 2, 2, 5, 1], 3]

Expected return

[[2, 4], [2, 5], [1, 5]]
Example 2

Arguments

[[8, 2], 3]

Expected return

[]
Example 3

Arguments

[[3, 3], 1]

Expected return

[[3, 3], [3, 3]]
Hint

Keep indices in two monotone deques: increasing values for minima and decreasing values for maxima.

The worked solution unlocks after completion, or with Premium access.

rolling_price_window.pyPython 3.12

Drafts are saved to your account, not to shared browser storage.

Sign in to submit code and save progress.

Results

Your results will appear here.

Hidden tests reveal only their pass/fail status, never their inputs or expected outputs. Runtime is observed wall time—not an inferred complexity class.

Join our Newsletter and Receive the Latest Updates!

Main Links

Trade Courses Assessments Interview Prep Contact Us

Social Media

Facebook Instagram YouTube

Legal

Terms and Conditions Privacy Policy Privacy settings

Talent Acquisition

Looking to hire exceptional quant talent?
See how we can help.

© 2026 EverythingQuant. All Rights Reserved.