Groupon Interview Question

Write an algorithm. Twice.