Pergunta de entrevista da empresa Nagarro

They just want you to justify your code properly and yes, the code should be in minimum time complexity.