Pergunta de entrevista da empresa Coupa Software Inc

Ruby problem based on the scenario