反转二叉树

static void reverseTree(final TreeNode root) {
    if (root == null) {
        return;
    }
    final TreeNode temp = root.right;
    root.right = root.left;
    root.left = temp;
    reverseTree(root.left);
    reverseTree(root.right);
}

参考:https://stackoverflow.com/questions/9460255/reverse-a-binary-tree-left-to-right

    原文作者:laosijikaichele
    原文地址: https://www.jianshu.com/p/996cecff876b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞