Quick Overview

Calculate how much rain water is trapped between nonnegative unit-width bars without mutating the input. A two-pointer scan tracks the highest boundary from each side, uses constant extra space, and handles totals beyond 32-bit range.

Calculate Trapped Rain Water

Company: Hive.Ai

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Overview: Calculate how much rain water is trapped between nonnegative unit-width bars without mutating the input. A two-pointer scan tracks the highest boundary from each side, uses constant extra space, and handles totals beyond 32-bit range.

Loading…