a = input()
b = input()
k = 0
a1, b1 = sorted(a), sorted(b)
if a1 == b1:
for i in range(len(a)):
if a[i] != b[i]:
k += 1
if k == 2:
print("YES")
else:
print("NO")
else:
print("NO")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
speed;
string s1,s2;
cin >> s1 >> s2;
unordered_set<char>st1, st2;
for(int i=0;i<s1.size();i++){
st1.insert(s1[i]);
}
for(int i=0;i<s2.size();i++){
st2.insert(s2[i]);
}
if(s1.size() != s2.size() || st2 != st1) {
cout << "NO";
return 0;
}
int cnt = 0;
for(int i=0;i<s1.size();i++) {
if(s1[i] != s2[i]) cnt++;
}
if(cnt == 0 || cnt == 2) cout << "YES";
else cout << "NO";
}
1031A - Golden Plate | 1559C - Mocha and Hiking |
427B - Prison Transfer | 330A - Cakeminator |
426A - Sereja and Mugs | 363A - Soroban |
1585C - Minimize Distance | 1506E - Restoring the Permutation |
1539A - Contest Start | 363D - Renting Bikes |
1198D - Rectangle Painting 1 | 1023B - Pair of Toys |
1725A - Accumulation of Dominoes | 1675E - Replace With the Previous Minimize |
839A - Arya and Bran | 16B - Burglar and Matches |
1625B - Elementary Particles | 1725G - Garage |
1725B - Basketball Together | 735A - Ostap and Grasshopper |
1183B - Equalize Prices | 1481A - Space Navigation |
1437B - Reverse Binary Strings | 1362B - Johnny and His Hobbies |
1299A - Anu Has a Function | 1111A - Superhero Transformation |
954A - Diagonal Walking | 39F - Pacifist frogs |
1451C - String Equality | 386A - Second-Price Auction |