## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Permutation And Median CodeChef Solution

Given a sequence $A$ of $N$ elements, Chef defines a function $F\left(i\right)$ $\left(1\le i\le N\right)$ as the median of the first $i$ elements of the sequence.

Chef wants to get a permutation $P$ of length $N$ such that ${P}_{i}=F\left(i\right)$ $\mathrm{\forall }$ $1\le i\le N$. Can you help Chef in achieving this?

Note that:

• The median of a sequence is the middle element in the sorted order of the sequence. If $N$ is even, choose the element at $\frac{N}{2}$ position in the sorted order. If $N$ is odd, choose the middle element.
• permutation of length $N$ is an array of $N$ integers $P=\left[{P}_{1},{P}_{2},\dots ,{P}_{N}\right]$ such that every integer from $1$ to $N$ (inclusive) appears in it exactly once. For example, $\left[2,5,4,1,3\right]$ is a permutation of
Solution Click Below:-  👉
👇👇👇👇👇

•  length $5$ while $\left[2,5,2,1,3\right]$ is not.

### Input Format

• First line will contain $T$, number of test cases. Then the test cases follows.
• Each test case consists of a single line of input, an integer $N$, the length of the required
•  permutation.

### Output Format

For each test case, output in a new line, $N$ space-separated integers, denoting a permutation satisfying the condition.

### Constraints

• $1\le T\le 700$
• $1\le N\le {10}^{5}$
• Sum of $N$ over all test cases does not exceed