Pergunta de entrevista da empresa IBM

Asked me to solve the same question i had solved in the coding round.