左耳听风ARTS第十三周

algorithms

226. Invert Binary Tree
Invert a binary tree.

Example:

Input:

     4
   /   \
  2     7
 / \   / \
1   3 6   9
Output:

     4
   /   \
  7     2
 / \   / \
9   6 3   1

Solution 1——leetcode上的思路:递归。递归的关键有三点:1、存在递归终止条件;2、一个问题的解可以分解为几个子问题的解;3、这个问题与分解之后的子问题,除了数据规模不同,求解思路完全一样。

/**
 * @author xiwam
 * @Date 2019/2/20 15:12
 * @Desc
 */
public class Solution {

    public TreeNode invert(TreeNode root) {

        if (root == null) {
            return null;
        }
        TreeNode temp = root.left;
        root.left = invert(root.right);
        root.right = invert(temp);
        return root;
    }

}

class TreeNode {

    int val;
    TreeNode left;
    TreeNode right;

    TreeNode(int value) {
        val = value;
    }
}

Review

The Problem With Logging
1、在高并发的情况下,log可能会引起乱序死锁的问题
2、减少不必要的日志打印,只打印必要的日志,如异常日志。

Tips

网络基础知识协议:DNS
1、dns服务器的树状结构。
在这里插入图片描述
2、dns的解析流程
在这里插入图片描述

Share

剖析一个java对象初始化顺序的问题

猜你喜欢

转载自blog.csdn.net/wuweiwoshishei/article/details/87820003