Goldman Sachs asked this puzzle in their Interview | Goldman Sachs Campus Hiring Program