IBM Interview Question

One algorithm problem, and one SQL problem.