Associated Course(s):
Fundamentals of Programming with C
Geeks Classes in Noida

Given an integer array **A**[] of size **N**. The task is to find the maximum of the minimum of every window size in the array.

**Note:** Window size varies from 1 to n.

**Input:**

The first line contains an integer T denoting the total number of test cases. In each test cases, the first line contains an integer N denoting the size of array. The second line contains N space-separated integers A_{1}, A_{2}, ..., A_{N} denoting the elements of the array.

**Output:**

In each seperate line, print the array of numbers of size N for each of the considered window size 1, 2 , ..., N respectively.

**Constraints:**

1 <= T <= 50

1 <= N <= 10^{5}

1 <= A[i] <= 10^{6}

**Example:**

**Input: **

2

7

10 20 30 50 10 70 30

3

10 20 30

**Output: **

70 30 20 10 10 10 10

30 20 10

**Explaination:**

**Testcase 1**:

First element in output indicates maximum of minimums of all windows of size 1. Minimums of windows of size 1 are {10}, {20}, {30}, {50}, {10}, {70} and {30}. Maximum of these minimums is 70.

Second element in output indicates maximum of minimums of all windows of size 2. Minimums of windows of size 2 are {10}, {20}, {30}, {10}, {10}, and {30}. Maximum of these minimums is 30.

Third element in output indicates maximum of minimums of all windows of size 3. Minimums of windows of size 3 are {10}, {20}, {10}, {10} and {10}. Maximum of these minimums is 20.

Similarly other elements of output are computed.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Change_UserHandle | 159 |

PankajChhabra1 | 62 |

SaswatMeher | 58 |

shivam2303 | 58 |

2017csb1106 | 51 |

KapilChhipa | 522 |

Sajid_Ali | 461 |

ApoorvaPrabhat10 | 458 |

sagarsagar | 450 |

ManiRamu | 433 |

blackshadows | 5254 |

Ibrahim Nash | 5184 |

akhayrutdinov | 5111 |

Quandray | 4385 |

mb1973 | 3828 |

Login to report an issue on this page.