# Trapping Rain Water — Aced (formerly Exponent)

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/1124/trapping-rain-water-in-bars
Source observed: 2026-11-05T00:09:29.876Z
Last checked: 2026-11-05T00:09:29.876+00:00
Indexed: 2026-11-07T03:18:20.586+00:00

---

# Trapping Rain Water

**Difficulty:** Hard  
**Category:** Data Structures & Algorithms; Coding

## Problem

Given an array of non-negative integers representing histogram bar heights, compute how much water can be trapped between the bars after rainfall. Each bar has width `1`. Water accumulates in dips between taller bars.

## Examples

- `Input: [5, 0, 4]` → `Output: 4` — the trapped amount is limited by the shorter bar.
- `Input: [1, 1, 1]` → `Output: 0` — no water can be trapped.

## Practice and access

We provide a question interface with **Question**, **Solution**, and **Community** tabs. The community area currently has no contributed answers in the supplied content. The page includes an editor and output/test-results panels; sign-up is required to run code: [Sign up to run code](https://www.aced.io/signup?src=lesson).

Detailed company statistics for this question require an upgrade: [Upgrade](https://www.aced.io/upgrade?src=questions).

## Interview activity

The question is listed with **+1015 interviews** and was reported as last asked **2 years ago**. 

- [Software Engineer](https://www.aced.io/questions?role=swe) — 9
- [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer) — 2
- [Data Engineer](https://www.aced.io/questions?role=data-engineer) — 2
- [Data Scientist](https://www.aced.io/questions?role=data-science) — 2

Associated companies listed include [Meta](https://www.aced.io/questions?company=meta-facebook) — 2, [Amazon](https://www.aced.io/questions?company=amazon) — 2, Apple, Visa, Adobe, Intuit, Service Now, PayPal, Tesla, Oracle, Goldman Sachs, Intel, and Citadel.

## Interview experiences

Two shared experiences are included:

- [Meta · 2 years ago](https://www.aced.io/experiences/meta-facebook-software-engineer-interview-1397a5): “Not a lot of time, have to solve 2 questions in an hour. Needed to budget my time wisely and make sure I can get both questions done.” **Software Engineer · Mid Level / L4**
- [Amazon · 2 years ago](https://www.aced.io/experiences/amazon-senior-software-engineer-interview-238c11): “The interview was really good All rounds where proper Coding round needs coder pad and really good” **Software Engineer · Senior / L5**

## Related courses

### [Machine Learning Engineer Interview Prep](https://www.aced.io/courses/ml-engineer)

![Machine Learning Engineer Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/6UfkHxUyLQVfDHSfLNQtWa/1be1539a65b4f6f15201f5b573c0a578/ML_Engineer_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for machine learning roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other companies through mock interviews, frameworks, and advice from senior candidates. Topics include ML system design, core concepts, coding, and behavioral interviews.

### [Data Science Interview Prep](https://www.aced.io/courses/data-science)

![Data Science Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/3U4C5C0OkDR0UeGch4AmlE/7ad489430b676a088cb973307fe77884/Data_Science_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We help candidates prepare for data science roles at Google, Amazon, Microsoft, Meta, Apple, and other companies through mock interviews, frameworks, and advice from senior candidates. Topics include statistics, experimentation, coding, SQL, machine learning, and behavioral interviews.

## Other Aced offerings

We provide interview preparation courses and practice for product management, forward-deployed engineering, engineering management, software engineering, system design, data science, machine learning, data engineering, AI engineering, investment banking, generative AI, security engineering, technical program management, solutions architecture, UX/product design, and BizOps & Strategy. We also offer interview experiences, coaching, resume review, salary negotiation, job referrals, resources, and business, university, recruiter, and affiliate programs.

[All Questions](https://www.aced.io/questions) · [Aced home](https://www.aced.io/?src=nav) · [Courses](https://www.aced.io/courses?src=nav) · [Experiences](https://www.aced.io/experiences?src=nav) · [Practice](https://www.aced.io/practice?src=nav) · [Pricing](https://www.aced.io/upgrade?src=nav)

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1124%2Ftrapping-rain-water-in-bars&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1124%2Ftrapping-rain-water-in-bars). Opening a form does not execute a tool.