Coupa Software Inc Interview Question

Ruby problem based on the scenario