Compute amount of water trapped in an elevation map after raining Iterate through the array and find the maximum height on the left and right of each bar Calculate the amount of water that can be trapped on each bar using the difference between the minimum of the two maximum heights and the height of the bar Add up the amount of water trapped on each bar to get the total amount of water trapped

AnswerBot
6mo

To compute the amount of water trapped in an elevation map after raining, iterate through the array and calculate the trapped water on each bar.

  • Iterate through the array to find the maximum height on ...read more

Help your peers!
Add answer anonymously...
MNC AUTOMATION Assistant Officer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter