摘要: Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node's value equals the given value. Retu 阅读全文
posted @ 2018-12-28 17:22 fatttcat 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally ident 阅读全文
posted @ 2018-12-28 17:17 fatttcat 阅读(85) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe 阅读全文
posted @ 2018-12-28 15:52 fatttcat 阅读(103) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: backtracking, 记得返回上层的时候删掉该层节点 time: O(n) -- visi 阅读全文
posted @ 2018-12-28 15:06 fatttcat 阅读(94) 评论(0) 推荐(0) 编辑
摘要: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a 阅读全文
posted @ 2018-12-28 13:23 fatttcat 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. Example: Input: Output: Trivia:This problem was inspired by this original tweet by Max Howell: time: O(n), space: O(logn) 阅读全文
posted @ 2018-12-28 11:05 fatttcat 阅读(86) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文
posted @ 2018-12-28 10:58 fatttcat 阅读(90) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the dep 阅读全文
posted @ 2018-12-28 10:54 fatttcat 阅读(96) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2018-12-28 09:38 fatttcat 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are n 阅读全文
posted @ 2018-12-28 09:07 fatttcat 阅读(113) 评论(0) 推荐(0) 编辑