We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
using namespace std;
int main(){
string s,t;
int a,b;
cin>>s>>t;
cin>>a;
int m = s.length();
int n = t.length();
int i = 0,j = 0;
while(s[i++] == t[j++]);
b = i-1;
if(a < (m-b) + (n-b)) cout<<"No";
else{
if(m == n && a >= m*2) cout<<"Yes";
else if((m-b) + (n-b) == a) cout<<"Yes";
else cout<<"No";
}
//cout<
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Append and Delete
You are viewing a single comment's thread. Return to all comments →
include
using namespace std; int main(){ string s,t; int a,b; cin>>s>>t; cin>>a; int m = s.length(); int n = t.length(); int i = 0,j = 0; while(s[i++] == t[j++]); b = i-1; if(a < (m-b) + (n-b)) cout<<"No"; else{ if(m == n && a >= m*2) cout<<"Yes"; else if((m-b) + (n-b) == a) cout<<"Yes"; else cout<<"No"; } //cout<