can anyone explain how this is done using dp,i am not able to understand its editorial.
Maybe this might help?