Skip to content

Commit

Permalink
Merge pull request #177 from Kaizo8/shreshth
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemincoder authored Apr 15, 2024
2 parents fd00c69 + eac8e26 commit 158d26a
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion easy/day_20/solution.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
//write your code here
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
if(n == 1){
cout << 1 << endl;
continue;
}
else if(n == 2){
cout << 1 << " " << 2 <<endl;
continue;
}
else if(n%2 !=0){
cout << -1 << endl;
continue;
}
else {
int arr[n];
for(int i = 1 ; i<= n ; i++){
arr[i] = i;
if(i%2 == 0) {
swap(arr[i] ,arr[i-1]);
}
}
for(int i = 1 ; i <= n ; i++){
cout << arr[i] << " ";
}
cout << endl;
}
}
return 0;
}

0 comments on commit 158d26a

Please sign in to comment.