Finding Smaller Towards Left And Right

easy
1. Given array A[] of integers, the task is to find the maximum absolute difference between nearest left and right smaller element of every element in array.
 2. If the element is the leftmost element, nearest smaller element on left side is considered as 0. 
 3. Similarly if the element is the rightmost elements, smaller element on right side is considered as 0.   
 4. Return the max absolute difference found.

Input Format

First line contain 'N'(size of the array). Second line contain N number of integer values.

Output Format

An integer

Constraints

1<=N<=100
 1<=A[i]<=100

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
7
2 4 8 7 7 9 3
Output
4
Previous
Largest Pair Of Smallest Elements
Next
Long Parenthesis

Related Questions