递归解

recursive solution