I was trying to solve this problem Container With Most Water
Steps of my algorithm:
- I will calculate(for each index i of array) the left farthest element of which is greater than or equal to arr[i]
- I will calculate(for each index i of array) the right farthest element of which is greater than or equal to arr[i]
- max_ar = max (mx_ar, min({left_far[i], right_far[i], arr[i]})*((r-i)+(i-l))); where l,r can be equal to i;