Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- #include <string>
- using namespace std;
- int main()
- {
- string a,b;
- cin >> a >> b;
- sort(a.begin(), a.end());
- sort(b.begin(), b.end());
- string c;
- int s = -1;
- for(int i = 0, j = 0; i < sizeof(a) || j < sizeof(b);){
- if(s == -1 || (a[i] == b[j] && a[i] != c[s])){
- c+=a[i];
- s++;
- }
- else if(a[i] > b[j]){
- j++;
- }
- else{
- i++;
- }
- }
- cout << c;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment