How to solve this problem using recursion ?
Container containing most water
hello @nidhigupta847
the approach is for each index i .
we will find index of max line to its left .
and the index of max line to its right.
and then our answer will be min( height[max_left_index] , height[max_right_index] ) *(max_right_index-max_right_index)
now to find left _max _index and right_max_index for each index i .we can use recursion.
recurrence relation.
left_max_index(i) = i if height[i] > height[ left_max_index(i-1) ]
otherwise
left_max_index(i) = left_max_index(i-1)
similary for right_max_index