Pregunta de entrevista de Walmart Global Tech

Two sum question was asked with modifications