Intuit Interview Question

average sql, and algorithms, not very original