Rain water harvesting


how should i improve the code plz also explain the loops

hello @utkarsh2504
for each i , we are calculating maximum array value to its left and to its right. then adding min(left,right)-a[i] to the answer.
also do check this article for better clarity->https://leetcode.com/problems/trapping-rain-water/solution/

thanks for assistance got it