Enter your book access code

The curriculum, drills, tutor, and interviewer mode are for readers of Ace the Rust Interview. The code is printed in the Preface (Companion site access).

Don’t have the book yet? The landing page stays open — purchase unlocks this gym.

intermediate · order 78

Longest subarray under budget

arr-window-02Related book chapters: 15 (optional — this page is complete on its own)variable-window

Slug: arr-window-02 · Paired reading: Chapter 15

Prompt

fn longest_under(nums: &[u32], budget: u32) -> usize — length of the longest contiguous subarray whose sum is ≤ budget. Variable sliding window; nums are non-negative.