You are viewing a single comment's thread. Return to all comments →
Here is my O(k) c++ solution, you can watch the explanation here : https://youtu.be/8ZOmXfo6k0Y
string appendAndDelete(string s, string t, int k) { if(k >= t.size() + s.size()) return "Yes"; int same = min(t.size(), s.size()); for(int i = 0; i< min(t.size(), s.size()); i++){ if(s[i] != t[i]){ same = i; break; } } k -= (s.size() - same); k -= (t.size() - same); return (k >= 0 && k%2 == 0)? "Yes":"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 →
Here is my O(k) c++ solution, you can watch the explanation here : https://youtu.be/8ZOmXfo6k0Y