Re: [algogeeks] Re: Interview Question based on histogram

2012-05-20 Thread Nikhil Agarwal
Navin , your reply is correct. On Sat, May 19, 2012 at 10:36 PM, Gene gene.ress...@gmail.com wrote: The problem is not so clear, so you must make some assumptions to gat an answer. Since we have water, we have to envision the histogram in 3d. Then assume that the distance between histogram

[algogeeks] Re: Interview Question based on histogram

2012-05-19 Thread Navin.nitjsr
we need to find the amount of water stored on every bar of the histogram. For this, we need to find two values :- v1 :- the highest bar to the left - O(n) v2:- the highest bar to the right - O(n) amount of the water stored on the current bar is Res= ( minimum of the two values(v1,v2) -

[algogeeks] Re: Interview Question based on histogram

2012-05-19 Thread Gene
The problem is not so clear, so you must make some assumptions to gat an answer. Since we have water, we have to envision the histogram in 3d. Then assume that the distance between histogram bars is 1 and bar i has height H[i], 0=iN, zero width and unit depth, and the base plane is at zero. Water