-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholliePS-15_SimilarStrings.cpp
58 lines (58 loc) · 1.19 KB
/
olliePS-15_SimilarStrings.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
49
50
51
52
53
54
55
56
57
58
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
for(int i = 1 ; i<=t ; i++)
{
int n;
cin>>n;
string s1 , s2;
cin>>s1>>s2;
string str1 , str2 , str11 , str22;
int count = 0;
for(int i = 0 ; i<n ; i++)
{
if(s1[i]==s2[i])
{
continue;
}
else if(s1[i] != s2[i])
{
count++;
if(count==1)
{
str1 = s1[i];
str2 = s2[i];
}
else if(count==2)
{
str11 = s1[i];
str22 = s2[i];
}
else if(count>2)
{
cout<<"No"<<endl;
break;
}
}
}
if(count==1)
{
cout<<"No"<<endl;
}
else if(count==2)
{
if(str1==str11 && str2==str22)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
}
return 0;
}