-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1291A - Even But Not Even.cpp
More file actions
94 lines (75 loc) · 1.41 KB
/
1291A - Even But Not Even.cpp
File metadata and controls
94 lines (75 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <climits>
#include <queue>
#include <stack>
#include <ctype.h>
#include <set>
#include <unordered_map>
#define ll long long
#define pb push_back
#define ArrayMaxLen 100001
#define vi vector<int>
#define vl vector<long long>
#define mod 1000000007
#define MAX 10000001
using namespace std;
void solve();
int main(){
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t=1;
cin>>t;
while(t--){
solve();
}
return 0;
}
string keypadCodes[] ={".;","abc", "def" ,"ghi","jkl","mno","pqrs","tu","vwx","yz"} ;
#define ppp pair<int,pair<int,int > >
void solve(){
//odd no of odds = > odd rahega
// even number of odds hona chahiye
//s[n-1] %2 !=0
//no of even 6+6+6+ 5+ 1+ 1
//first remove all the even nos.
// if odd %2== 0 ==> remove 1 odd no.
int n;
cin>>n;
string s;
cin>>s;
string ans;
int odd = 0 ;
for(int i =0 ;i<n;i++){
int curr = s[i]-'0';
if(curr%2!=0){
odd++;
ans+=s[i];
}
}
if(odd==0){
cout<<"-1\n";
}
else if(odd%2==0){
cout<<ans<<"\n";
}else{
ans.pop_back();
if(ans.size()==0){
cout<<"-1\n";
}
else{
cout<<ans<<"\n";
}
}
}