You are viewing a single comment's thread. Return to all comments →
Case B:
I wil try my level best to explain
eg:
s=hackerrank
t=hackerearth
k=11
ls=length of s =10
lt=length of t=11
ls+lt=21
commonlength=6
21-2*6=21-12=9
t=hackerrank
we use 4 moves to delete "rank"
t=hacker
we have moves=k-4=11-4=7 left
we need 5 moves to append "earth"
moves=7-5=2 left
following is the explanation we will use thise extra 2 moves
s=hacker->hacke->hacker->hackerearth
explanation=(original string)->(remove r)->(append r)->(append "earth")
moves=(7)->(6)->(5)->(0)
s=t is acheived
if k were to be an even number then this would not have been possible
it will be only possible if (ls+lt-2*commonlength) is even and k is even
hope my explanation help some one in need
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 →
Case B:
I wil try my level best to explain
eg:
s=hackerrank
t=hackerearth
k=11
ls=length of s =10
lt=length of t=11
ls+lt=21
commonlength=6
21-2*6=21-12=9
t=hackerrank
we use 4 moves to delete "rank"
t=hacker
we have moves=k-4=11-4=7 left
we need 5 moves to append "earth"
moves=7-5=2 left
following is the explanation we will use thise extra 2 moves
s=hacker->hacke->hacker->hackerearth
explanation=(original string)->(remove r)->(append r)->(append "earth")
moves=(7)->(6)->(5)->(0)
s=t is acheived
if k were to be an even number then this would not have been possible
it will be only possible if (ls+lt-2*commonlength) is even and k is even
hope my explanation help some one in need