Implement prototype(loads, width) and solve(loads, width). Return maxima for all full contiguous windows in increasing start order. Negative values and duplicates are valid. Empty input or width>loads.length returns []. width<=0 throws RangeError even for empty input.
[9, 8, 7, 6] with width 2 returns [9, 8, 7]; [4, 4, 1, 4] with width 2 returns [4, 4, 4].
Prototype: scan each window. Final: candidate indices in a monotonic deque, O(n) time/O(width) auxiliary space. Preserve input on success and failure.
All numeric inputs and finite arithmetic results in this lesson are safe-integer Numbers. Use null for documented absence, not undefined or a numeric sentinel. Return actual booleans where the contract requires them. Do not add validation requirements beyond the documented inputs.
Run with Node.js 20+ from this directory:
node main.mjs --stage prototype
node main.mjs --stage finalEdit exercise.mjs; keep main.mjs unchanged. Both stages begin as unfinished learner functions. The website uses the same test functions in a separate browser worker. Tests check deterministic examples, boundaries, documented validation, input preservation, and stage-specific cases. Passing tests does not prove the required time complexity.
Complete the starter code, then run the checks.
Results and errors will appear here.