Given an array A of size N, A[i] represents the height of pillar at A[i]th x coordinate.
let A={3,8,5} then it means height of pillar at x=3 is 3 and x=8 is 8 and x=5 is 5 the what is the maximum area between any two pillar. In the above case the answer is maxArea=15 i.e. between 3 and 8. The area between two pillar at index i,j is defined as area=min(A[i],A[j])*(abs(A[]i-A[j])).
constraints
1<=n<=5*103
1<=A[i]<=109
NOTE:
Please do not propose the O(N2) solution.