
Asked in Mobikwik
Trapping Rain Water
You are provided with an array ARR
of integers representing an elevation map, where ARR[i]
denotes the elevation of the ith
bar. Determine the maximum amount of rainwater that can be trapped between these bars.
Input:
The first line contains an integer 'T', the number of test cases.
For each test case:
The first line contains an integer 'N', the size of the array/list.
The second line consists of 'N' space-separated integers representing the heights of the bars.
Output:
For each test case, output a single integer representing the total volume of trapped rainwater.
Example:
Input:
2
4
0 1 0 2
6
0 1 3 0 1 2
Output:
1
5
Constraints:
1 <= T <= 10
0 <= N <= 104
0 <= ARR[i] <= 109
- Time Limit: 1 sec
Note:
The width of each bar is 1. You are not required to print anything; the printing is already taken care of by the provided function definition.

AnswerBot
4mo
Given an array representing an elevation map, find the maximum amount of rainwater that can be trapped between the bars.
Iterate through the array and calculate the maximum height on the left and right...read more
Help your peers!
Add answer anonymously...
Top Software Developer Interview Questions Asked at Mobikwik
Q. Maximum Subarray Sum Problem Statement Given an array of integers, determine the...read more
Q. Reverse Linked List Problem Statement Given a singly linked list of integers, re...read more
Q. Kth Smallest Element Problem Statement You are provided with an array of integer...read more
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Mobikwik Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

