Skip to content

Commit

Permalink
feat: day 20 easy solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaizo8 committed Apr 14, 2024
1 parent fd00c69 commit 5a78ada
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion easy/day_20/solution.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
//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;
}
if(n==4){
cout << "3 4 1 2" << endl;
continue;
}
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 && i!=2){
swap(arr[i] , arr[i-2]);
}
}
for(int i = 1 ; i<=n ; i++){
cout << arr[i] << " ";
}
cout << endl;
}
}
return 0;
}

0 comments on commit 5a78ada

Please sign in to comment.