zoukankan      html  css  js  c++  java
  • LintCode翻转二叉树

    /**
     * Definition of TreeNode:
     * public class TreeNode {
     *     public int val;
     *     public TreeNode left, right;
     *     public TreeNode(int val) {
     *         this.val = val;
     *         this.left = this.right = null;
     *     }
     * }
     */
    public class Solution {
        /**
         * @param root: a TreeNode, the root of the binary tree
         * @return: nothing
         */
        public void invertBinaryTree(TreeNode root) {
            // write your code here
           if(root==null)
            return;
           invertBinaryTree(root.left);
           invertBinaryTree(root.right);
           swap(root);
        }
        public void swap(TreeNode root)
        {
            TreeNode temp=root.left;
            root.left=root.right;
            root.right=temp;
        }
    }
    
  • 相关阅读:
    vue $emit的使用
    flask config 环境变量配置
    get请求
    下载及安装
    测试用例写作
    系统测试
    测试方法
    软件质量
    测试基础
    子网掩码
  • 原文地址:https://www.cnblogs.com/temporary/p/7491023.html
Copyright © 2011-2022 走看看