Shop Bonsai interview question

One typical algorithm question and logic problems.