Smaller On Left

easy
1. Given an array arr[] of N positive integers. 2. The task is to find the greatest smaller on left of every element in the array.

Input Format

First line of input contains size of array N. Next line contains 'N' array elements.

Output Format

Return an integer array.

Constraints

1 <= N <= 106
 1 <= arr[i] <= 108

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
5
2 3 4 5 1
Output
-1 2 3 4 -1
Previous
Frequency Of Limited Range Array Elements
Next
Smallest Distinct Window

Related Questions