I’m not able to understand the issue with my code here.
Rainwater harvesting
@armaanbhardwaj23 could you explain me what logic you have used in your code cause to me it seems you are just adding 2 when a[i]=0 and 1 when a[i]=1,why do you think simply adding 1 and 2 will give you correct answer.
I got it.actually I misunderstood the problem and wrote the code in order to satisfy just the first test case
ok nice. if you get any further queries let me know else mark this doubt resolved.
1 Like
its showing TLE now.
that may be cause your code is of O(n^2), try thinking an efficient way, like precalculate left and right max for every bars.