forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path(LEETCODE)minStepsAnagram.cpp
48 lines (36 loc) · 978 Bytes
/
(LEETCODE)minStepsAnagram.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
43
44
45
46
47
48
#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
int minSteps(string s, string t) {
set<char, char> S;
int count = 0;
for(int i=0;i<s.length();i++){
// pair<char, char> x = make_pair(s[i], t[i]);
S.insert(s[i], t[i]);
count++;
}
//map<char, char>::iterator itr;
set<char, char>::iterator itr;
for(itr=S.begin(); itr!=S.end(); itr++){
//if(x.first==x.second){
cout << *itr[0] << " " << *itr[1] << endl;
//}
}
// for(itr = mp.begin(); itr!=mp.end(); itr++){
// if(mp.find(itr->second)){
// cout << itr->first << " " << itr->second << endl;
// }
// }
cout << endl;
cout << s.length() - count;
return 0;
}
};
int main(){
string s = "friend";
string t = "family";
Solution sol;
sol.minSteps(s, t);
return 0;
}