Solve four classic algorithm problems | Microsoft Interview Question