Solving an interview question