摘要:
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 t... 阅读全文
摘要:
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 following is ... 阅读全文
摘要:
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to 4 / \ 7 2 / \ / \ 9 6 3 1 /** * Definition for a binary tree node. * struct TreeNode { * int val; ... 阅读全文