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.
You comment helped me a lot when I was two pints away from the score. Thanks mate.
Here I am posting my code in C++
int main()
{
string s;
std::cin>>s;
string t;
std::cin>>t;
int k;
cin >> k;
int cmon_len=0;
while(s[cmon_len] == t[cmon_len] && cmon_len < s.size())
++cmon_len;
std::string result = "No";
//This case is for when two strings are unique
if(!cmon_len)
result = s.size() + t.size() <= k ? "Yes" : "No";
//This case is for when both the string size are equal
bool is_same = (s.size() == cmon_len && t.size() == cmon_len);
if(is_same)
result = (s.size() + t.size() <= k || k > 1) ? "Yes" : "No";
auto rem_t = t.size() - cmon_len;
auto rem_s = s.size() - cmon_len;
if(s.size() < t.size())
result = (t.size() - s.size())%2 == k%2 ? "Yes" : "No";
else
result = rem_t+rem_s <= k ? "Yes" : "No";
std::cout<<result<<std::endl;
return 0;
Append and Delete
You are viewing a single comment's thread. Return to all comments →
You comment helped me a lot when I was two pints away from the score. Thanks mate.
Here I am posting my code in C++
int main() { string s; std::cin>>s;
}