Pergunta de entrevista da empresa Tata Consultancy Services

Question on string and DP.