Question i am not able to buid a logic

i am not able to get the logic how to solve this