-
Notifications
You must be signed in to change notification settings - Fork 0
/
test24_25.cpp
43 lines (38 loc) · 803 Bytes
/
test24_25.cpp
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
#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;
void find_first_in_a_notin_b(string& x, string& y)
{
unordered_set<char> hashset;
for (auto c : y) {
hashset.insert(c);
}
for (auto c : x) {
if (hashset.find(c) == hashset.end()) {
cout << c << endl;
break;
}
}
}
string& find_in_a_notin_b(string& x, string& y)
{
unordered_set<char> hashset;
static string s;
for (auto c : y) {
hashset.insert(c);
}
for (auto c : x) {
if (hashset.find(c) == hashset.end()) {
s += c;
}
}
return s;
}
int main()
{
string x = "qwerttyuuafzwerxtcfyvgubhinjomk",
y = "wesrdtvyg",
z = find_in_a_notin_b(x, y);
cout << z << endl;
}