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.
publicstaticStringappendAndDelete(Strings,Stringt,intk){// Write your code hereintlength_s=s.length();intlength_t=t.length();if(k>=length_s+length_t)return"Yes";else{intdifferenciator=0;intmin_operations=0;for(inti=0;i<(length_s>=length_t?length_t:length_s);i++){if(s.charAt(i)==t.charAt(i))differenciator++;elsebreak;}min_operations=(length_s-differenciator)+(length_t-differenciator);if(k<min_operations)return"No";elseif(k==min_operations)return"Yes";else{if(min_operations%2==0){if(k%2==0)return"Yes";elsereturn"No";}else{if(k%2!=0)return"Yes";elsereturn"No";}}}}
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 →
My JAVA Solution: