Trapping rain water

Question:-https://practice.geeksforgeeks.org/problems/trapping-rain-water/0#
My code:-
https://ide.codingblocks.com/s/367915

Can you tell me where am I going wrong?

hello @div_yanshu07

check now->

now it will give tle because its time complexity is O(n^2).

try to solve it in O(n) .
note : max element function works in O(n)