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.
defappendAndDelete(s,t,k):# Write your code here#all cases where the length of the two strings combined is less than or equal to k workiflen(t)+len(s)<=k:return'Yes'index=0whileTrue:#remove the out of index range scenarioifindex>len(s)-1orindex>len(t)-1:break#determine up to which index is the sameifs[index]==t[index]:index+=1else:break#determine remaining steps needed and if the difference between remaining and k is either 0 or evenremaining_steps=len(s)+len(t)-index*2ifremaining_steps<=kand(k-remaining_steps)%2==0:return'Yes'else:return'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 →
python