原文:[LeetCode] Lowest Common Ancestor of a Binary Tree

Lowest Common Ancestor of a Binary Tree Given a binary tree, find the lowest common ancestor LCA of two given nodes in the tree. According to thedefinition of LCA on Wikipedia: The lowest common ances ...

2015-07-13 20:40 0 4076 推薦指數:

查看詳情

236. Lowest Common Ancestor of a Binary Tree

題目: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia ...

Sun Nov 29 07:56:00 CST 2015 0 2115
[Leetcode] Balanced Binary Tree

問題:給一個二叉樹,寫一個算法判斷這個樹是不是balanced。 Solution #1. 第一次遇到這個問題時我的解法,如下: 寫了一個getDepth()函數,訪問每個節點都要調用一次這個函數。這個Solution也通過了leetcode的驗證程序,但是后來想了想,I ...

Sun May 04 08:58:00 CST 2014 2 6363
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM