Doubt with similar trapping rainwater

why technique of left and right array to store max doesnt work here,and then why it work in trapping rainwater problem

@rbpagire the problems are totally different!(only water is common in both :joy:)
in this problem you only have to consider one container!, so you need to find maximum of min(a[i],a[j])X(j-i+1) for 0<=i<j<=n-1.
Think of two pointer approach!