{"id":"hills-valleys-two-pass-tradeoff","text":"`count_hills_and_valleys` uses O(n) auxiliary space for the `deduped` list (two-pass: dedup then scan); a single-pass approach tracking `prev_different` could reduce to O(1) space.","truth_value":"IN","source":"entries/2026/06/06/count-hills-and-valleys-in-an-array-solution.md","source_url":"","source_hash":"","justifications":[],"dependents":[],"metadata":{},"created_at":"","updated_at":"","reviewed_at":"","verified_at":"","retracted_at":"","explanation":{"steps":[{"node":"hills-valleys-two-pass-tradeoff","truth_value":"IN","reason":"premise"}]}}