Pregunta de entrevista de Cognam Technologies

They asked me to write the code for leetcode question 3.