Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve()
- {
- int cnt = 0;
- string a, b;
- cin >> a >> b;
- map<char, int> m1, m2;
- for (int i = 0; i < a.length(); i++)
- {
- if (a[i] != b[i])
- cnt++;
- m1[a[i]]++;
- m2[b[i]]++;
- }
- bool flag = true;
- map<char, int>::iterator it1 = m1.begin();
- map<char, int>::iterator it2 = m2.begin();
- while (it1 != m1.end())
- {
- if (it1->first != it2->first or it1->second != it2->second)
- {
- flag = false;
- }
- it1++, it2++;
- }
- cout << (flag and cnt ? "YES" : "NO") << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment