LeetCode - Binary Tree Postorder

2019-07-19  本文已影响0人  Andy1944

Binary Tree Postorder Traversal - LeetCode

Solution

class Solution {
    func postorderTraversal(_ root: TreeNode?) -> [Int] {
        guard let root = root else {
            return []
        }
        return postorderTraversal(root.left) + postorderTraversal(root.right) + [root.val]
    }
}

上一篇 下一篇

猜你喜欢

热点阅读