Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question 70 #153

Open
Mahi1901 opened this issue Oct 23, 2022 · 5 comments
Open

Question 70 #153

Mahi1901 opened this issue Oct 23, 2022 · 5 comments

Comments

@Mahi1901
Copy link
Collaborator

Given a positive integer n and an integer kk such that 0≤k≤n, find any permutation A of 1,2…n such that the number of indices for which Ai=i is exactly k. If there exists no such permutation, print −1. If there exist multiple such permutations, print any one of them.

Input Format
First line of the input contains T, the number of test cases. Then the test cases follow.
Each test case contains a single line of input, two integers n, k.
Output Format
For each test case, print a permutation in a single line, if a permutation with the given constraints exists. Print −1 otherwise.

Constraints
1≤T≤10^5
1≤n≤10^5
0≤k≤n
Sum of n over all test cases doesn't exceed 2⋅10^6.

Sample 1:
Input
3
2 1
3 1
4 2

Output
-1
1 3 2
3 2 1 4

@ghost
Copy link

ghost commented Oct 23, 2022

Can you please assign this issue to me? I have the best possible solution for this problem, also I have explained every step of my code.

@Mahi1901
Copy link
Collaborator Author

Mention college name, year and branch.
@Sid21112002

@ghost
Copy link

ghost commented Oct 23, 2022

Jalpaiguri Government Engineering College
2nd year, Information Technology Department

@Mahi1901 Mahi1901 assigned ghost Oct 23, 2022
@Mahi1901
Copy link
Collaborator Author

I have assigned, Happy coding!

@NikitaMiraje
Copy link
Contributor

Nikita Miraje
Cummins college of engineering for women
Dept: Electronics and telecommunication
I would like to work on this issue. Can you please assign me this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants