Shop Bonsai Interview Question

One typical algorithm question and logic problems.