adplus-dvertising

Permutation Creation Codechef Solution

We Are Discuss About CODECHEF SOLUTION

Permutation Creation Codechef Solution

Permutation Creation Codechef Solution

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

Problem

JJ gives you a number N and challenges you to construct a permutation P of length N such that:

  • |P_{i + 1} – P_i| \ge 2¬†for all¬†1 \le i \le N – 1¬†(Here¬†|x|¬†denotes the absolute value of¬†x)

Can you complete JJ’s challenge?

As a reminder, a permutation of length N is an array where every integer from 1 to N occurs exactly once.

Input Format

  • The first line contains a single integer¬†T¬†‚ÄĒ the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains one integer¬†N¬†‚ÄĒ the length of the permutation¬†P¬†to be constructed.

Output Format

For each test case, output N space-separated integers P_1, P_2, \ldots, P_N denoting the permutation P which satisfies the given conditions.

If no such permutation exists, output -1.

If there are multiple answers, print any.

Constraints

  • 1 \leq T \leq 10^5
  • 2 \leq N \leq 10^5
  • Sum of¬†N¬†over all test cases does not exceed¬†2 \cdot 10^5

Sample 1:

Input

Output

2
2
6
-1
1 4 2 5 3 6

Explanation:

Test Case 1: It can be proven that no permutation of length 2 exists that satisfies the given conditions.

Test Case 2: [1, 4, 2, 5, 3, 6] satisfies the given condition, since |P_{i + 1} РP_i| \ge 2 for all 1 \le i \le N Р1

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

 

SOLUTION

Here Discuss About Permutation Creation Codechef Solution

SOLUTION

Permutation Creation Codechef Solution

SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

Leave a Reply

Your email address will not be published.