-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path20_Question.cpp
More file actions
54 lines (46 loc) · 1.49 KB
/
20_Question.cpp
File metadata and controls
54 lines (46 loc) · 1.49 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
// Jack and Jill are playing a string game. Jack has given Jill two strings A and B. Jill has to derive a string C from A, by deleting elements from string A, such that string C does not contain any element of string B. Jill needs help to do this task. She wants a program to do this as she is lazy. Given strings A and B as input, give string C as Output.
// Example 1:
// Input:
// tiger -> input string A
// ti -> input string B
// Output:
// ger -> Output string C
// Explanation:
// After removing “t” and “i” from “tiger”, we are left with “ger”.
// So, the answer is “ger”.
// Example 2:
// Input:
// processed -> input string A
// esd -> input string B
// Output:
// proc -> Output string C
// Explanation:
// After removing “e” “s” and “d” from “processed”, we are left with “proc”.
// So, the answer is “proc”.
// Example 3:
// Input:
// talent -> input string A
// tens -> input string B
// Output:
// al -> Output string C
// Explanation:
// After removing “t” “e” and “n” from “talent”, we are left with “al”.
// So, the answer is “al”.
#include<bits/stdc++.h>
using namespace std;
string removeChar(string& A, string& B){
string res;
for(auto ch : A){
if(B.find(ch) == string::npos){
res += ch;
}
}
return res;
}
int main(){
string A,B;
cin>>A;
cin>>B;
cout<<removeChar(A,B);
return 0;
}