Technical Associate Interview Questions

2,998 technical associate interview questions shared by candidates

Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. Examples: Input: arr[] = {2, 0, 2} Output: 2 Structure is like below | | |_| We can trap 2 units of water in the middle gap. Input: arr[] = {3, 0, 0, 2, 0, 4} Output: 10 Structure is like below | | | | | | |__|_| We can trap "3*2 units" of water between 3 an 2, "1 unit" on top of bar 2 and "3 units" between 2 and 4. See below diagram also. Input: arr[] = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] Output: 6 | | || | _|_||_|||||| Trap "1 unit" between first 1 and 2, "4 units" between first 2 and 3 and "1 unit" between second last 1 and last 2
avatar

Technical Associate

Interviewed at Zillious

3.8
Oct 29, 2017

Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. Examples: Input: arr[] = {2, 0, 2} Output: 2 Structure is like below | | |_| We can trap 2 units of water in the middle gap. Input: arr[] = {3, 0, 0, 2, 0, 4} Output: 10 Structure is like below | | | | | | |__|_| We can trap "3*2 units" of water between 3 an 2, "1 unit" on top of bar 2 and "3 units" between 2 and 4. See below diagram also. Input: arr[] = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] Output: 6 | | || | _|_||_|||||| Trap "1 unit" between first 1 and 2, "4 units" between first 2 and 3 and "1 unit" between second last 1 and last 2

Viewing 581 - 590 interview questions

See Interview Questions for Similar Jobs

Glassdoor has 2,998 interview questions and reports from Technical associate interviews. Prepare for your interview. Get hired. Love your job.