Given an array of integers **A** of size **N**.

Find and return an array containing the **maximum of the minimum(s)** of every window size in the array. The window size varies from **1** to **N**.

For example, given **A = [6, 3, 5, 1, 12]**, consider window sizes of **1** through **5**.

Windows of size **1** are **[6], [3], [5], [1], [12]**. The **maximum of the minimum(s)** values of these windows is **12**.

Windows of size **2** are **[6, 3], [3, 5], [5, 1], [1, 12]** and their **minima** are **{3, 3, 1, 1}**. The **maximum** of these values is **3**.

Continue this process through window size **5** to finally consider the entire array. All of the answers are **[12, 3, 3, 1, 1]**.

**Input Format**

```
The first and only argument given is the integer array A.
```

**Output Format**

```
Return an array containing the maximum of the minimum(s) of every window size in the array. The window size varies from 1 to N.
```

**Constraints**

```
1 <= N <= 1000000
1 <= A[i] <= 100000
```

**For Example**

```
Example Input 1:
A = [3, 5, 4, 7, 6, 2]
Example Output 1:
[7, 6, 4, 4, 3, 2]
Example Explanation 1:
win size w_1 w_2 w_3 w_4 w_5 w_6 maximum of all windows
1 3 5 4 7 6 2 7
2 3 4 4 6 2 6
3 3 4 4 2 4
4 3 4 2 4
5 3 2 3
6 2 2
Input 2:
A = [2, 6, 1, 12]
Output 2:
[12, 2, 1, 1]
```

NOTE:You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.

Sign Up

to access hints and editorial solutions for**MIN MAX RIDDLE**

to access hints and editorial solutions for

Loading...