Apple Interview Question

logic design problems