Sign In
You are coding as a Guest. Sign in with Google in 1 tap to save your daily streak, lock in +50 XP & boost your college rank!
Save Streak (1-Tap Google)
9:00 AM Daily Incident ReleaseMaintaining a 7-day streak grants a 2.5× Recruiter Visibility Multiplier on the Recruiter Talent Radar.
Multiplier Ladder:1d: 1.0ו3d: 1.5ו7d: 2.5× MAX
🔥Trapping Rain Water: Monotonic Elevation TrapHard
SUPER HARD PROBLEM OF THE DAY+150 XP • FAANG OA TIER

High-difficulty challenge matching authentic Google, Amazon & Uber L5 online assessment conditions.

HardTwo Pointers•Acceptance: 61.2%

Trapping Rain Water: Monotonic Elevation Trap

Targeted in FAANG & Tech OA:GoogleAmazonMicrosoft
Real-World Engineering Context
Applied in GIS topographical hydrology modelling and reservoir watershed simulations at Google Maps and Earth Engine to calculate surface water runoff retention.
Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. Water can only be trapped between two higher boundaries. The trapped water at any index is `min(maxLeft, maxRight) - height[i]`.

Sample Test Cases

Input: [[0,1,0,2,1,0,1,3,2,1,2,1]]
Expected: 6
Input: [[4,2,0,3,2,5]]
Expected: 9
Input: [[3,3,3,3]]
Expected: 0

Constraints

  • n == height.length
  • 1 <= n <= 2 * 10^4
  • 0 <= height[i] <= 10^5
Verified Proof-of-Work ATS PortfolioCryptographic Verification
Export tamper-proof problem verifications to your direct ATS applications
DevScore: Unranked (0/1000)

Every verified problem solve writes authentic cryptographic proof-of-work to your profile. Attach your verified DevScore badge to ATS applications to stand out to engineering hiring teams across 4,000+ verified live tech openings (23,000+ cumulative audited) on RoleNest.

Explore 4,000+ Direct ATS Openings on RoleNest ↗Solve Challenge to Activate Ledger