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.
Hi I tried with no more than a simple if else and I could, just my logic is kind of weird but works.
publicstaticStringappendAndDelete(Strings,Stringt,intk){// Write your code hereintuno=s.length();intdos=t.length();if(s.equals(t)){return"Yes";}elseif(s.length()>t.length()&(uno-dos)>k){return"No";}elseif(s.length()<t.length()&(dos-uno)==k/2&s.charAt(uno-1)==t.charAt(dos-1)){return"Yes";}elseif(s.length()<t.length()&(dos-uno)<k){return"No";}elseif(s.length()==t.length()&(uno/2)>k/2){return"No";}elseif(s.charAt(0)!=t.charAt(0)&&s.length()>k/2){return"No";}return"Yes";}}
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 →
Hi I tried with no more than a simple if else and I could, just my logic is kind of weird but works.