Pregunta de entrevista de Prudential

Explain your methodology for solving the programming problem.