Not able to get the idea < Sanket and Strings >

not able to get the logic to solve it…

hey @rprahulpal03
check this for logic Please give some hint to solve this problem