
LeetCode_Tree算法
文章平均质量分 79
sunp823
积跬步,至千里;积小流,成江海
展开
-
LeetCode_Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the原创 2015-05-02 21:24:00 · 290 阅读 · 0 评论 -
LeetCode之Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the followi原创 2015-05-11 20:17:56 · 299 阅读 · 0 评论 -
LeetCode--Sum Root to Leaf Numbers
题目: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the to原创 2015-05-19 00:35:12 · 412 阅读 · 0 评论 -
二叉树最近公共祖先节点
寻找最近公共祖先节点(LCA) 在一棵二叉树中,对于节点X和节点Y,X和Y的LCA是这棵树中X和Y的第一个共同祖先。寻找公共节点的算法思路很简单:对于节点x和y,找到树的根节点分别到x节点和y节点的路径(并不是遍历),并分别记录在两个数组中(或其他),数组中索引为0的元素为树的根节点,索引越小的元素离待x和y节点越远。且两个数组前面肯定有对应相同的元素。此时问题变为正向查找两个数组中第一个不相同原创 2015-07-13 15:39:22 · 1465 阅读 · 0 评论