Putnam Interview Question

Standard case.