You are viewing a single comment's thread. Return to all comments →
C++
string appendAndDelete(string s, string t, int k) { int same_letters = 0; int cnt1 = s.size(); int cnt2 = t.size(); int min_val = min(cnt1, cnt2); for (int i = 0; i < min_val; i++) { if (s[i] == t[i]) { same_letters++; } else break; } int amount = (cnt1 - same_letters) + (cnt2 - same_letters); if (amount == k) { return "Yes" ; } else if (amount < k) { if ((k - amount) % 2 == 0 || k >= cnt1 + cnt2) { return "Yes"; } } return "No"; }
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 →
C++