forked from CodeToExpress/dailycodebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
day7.cpp
65 lines (59 loc) · 1.19 KB
/
day7.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
59
60
61
62
63
64
65
/*
* @author : dhruv-gupta14
* @date : 28/12/2018
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int flag=0,x=0;
string str1;
getline(cin,str1);
string str2;
getline(cin,str2);
int n = str1.length();
int m = str2.length();
if(str1 == str2)
cout << "Yes";
else if(n==m && str1 !=str2){
for(int i=0; i<n; i++)
{
if(str1[i] != str2[i])
flag++;
}
if(flag == 1)
cout << "Yes";
else
cout << "No";
} else{
if(n == m+1)
{
x=0;
for(int j=0; j<n; j++)
{
if(str1[j] != str2[x])
{
flag++;
}else{
x++;
}
}
}else if(m == n+1){
x=0;
for(int k=0; k<m; k++)
{
if(str1[x] != str2[k])
{
flag++;
}else{
x++;
}
}
}
if(flag == 1)
cout << "Yes";
else
cout << "No";
}
return 0;
}