Pergunta de entrevista da empresa Scientific Games

Basic way to solve the problem in code