[Discuss] TRAPPING RAIN WATER

Hey folks,
Let’s discuss anything related to the TRAPPING RAIN WATER problem in this thread

Perf test cases are failing. Please tell what aspect these cases are related to.

edge-test-3 is failing. please help

edge-test-3 is failing. please help

check for input size 0

4 Likes

Performance cases could have thousands of entries.

Where can I find the hint for pseudocode?

@gouravsardana @Kiran
5 cases are failing,base test 3 4 5,edge test 6 and performance test 6…cant figure out the error…used dp based approach

oh…made an minor error…issue resolved

perf-test-3,4,6 are failing, even though the same code passes all cases on Leetcode. Any help ?

P.S : O(n) time and O(n) space

I resolved it by decreasing the number of passes over the same array, earlier my time complexity was O(3n), now it is O(2n), still using 2 passes but now the perf-test cases are passing.

what should be the unit for elevation map y-axis .
should be unitary or could change to situation as in 2nd Example 50,100,150 if the input was 50,0,100,150 should the output be 1 or 50.

The unit for y-axis would be 1. And it does not change.

The output in this case would be 50.

I am not able to pass perf test cases even though the time complexity is O(n) i.e.(2*n) with max and min calculation

Do you see Timeout or Failed if the test results? If it is Timeout optimization is needed.

Recheck your time complexity. It might be 0(n2). You can improve it by using DP.

why am I failing edge-test-3.
Any suggestions ??

It is giving me compilation errors in the failed build result though I have successfully compiled the code on machine and also passed its pre-build testcases ,i.e, sample test cases it provide. Any help is much appreciated.

I am getting timedout in perf-test 3, 4 and 6. I tried checking hints but as soon as I clicked the show hint, it didn’t show any hints and the hints are locked is displayed. Can someone guide me some hints or pseudocode about how to optimize the solution.

Check for empty input array