Pergunta de entrevista da empresa Rently

The second round program given to me has constrains of input value is 10^9.