LeetCode ----- Tree
ReedLi
on the way
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two原创 2016-07-19 21:27:01 · 363 阅读 · 0 评论 -
Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to 4 / \ 7 2 / \ / \ 9 6 3 1递归算法: 1、交换根节点的左右子树。 2、对左右子树分别执行递归交换 。代码如下:/** * Definition for a binary tree no原创 2016-07-20 08:28:42 · 480 阅读 · 0 评论
分享