Obviously, the straightforward method is faster because there aren't any function calls or stack manipulation, but the recursive way is more elegant and better reflects the problem.
Obviously, the straightforward method is faster because there aren't any function calls or stack manipulation, but the recursive way is more elegant and better reflects the problem.
很明显,直接方法执行速度要快一些,因为没有涉及到任何函数调用或堆栈操作。