随笔分类 -  tree(dfs)

662. Maximum Width of Binary Tree
摘要:Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binar 阅读全文

posted @ 2018-11-30 07:32 猪猪🐷

863. All Nodes Distance K in Binary Tree
摘要:We are given a binary tree (with root node root), a target node, and an integer value K. Return a list of the values of all nodes that have a distance 阅读全文

posted @ 2018-11-08 16:17 猪猪🐷

742. Closest Leaf in a Binary Tree
摘要:Given a binary tree where every node has a unique value, and a target key k, find the value of the nearest leaf node to target k in the tree. Here, nearest to a leaf means the least number of edges t... 阅读全文

posted @ 2018-11-07 05:09 猪猪🐷

199. Binary Tree Right Side View
摘要:( bfs is easy, instead use preorder dfs right first and then left) Given a binary tree, imagine yourself standing on the right side of it, return the 阅读全文

posted @ 2018-08-11 04:39 猪猪🐷

257 binary tree paths
摘要:https://github.com/tongzhang1994/Facebook-Interview-Coding/blob/master/257.%20Binary%20Tree%20Paths.java Given a binary tree, return all root-to-leaf 阅读全文

posted @ 2018-08-11 04:38 猪猪🐷

333. Largest BST Subtree
摘要:333. Largest BST Subtree I feel this is post order traversal https://www.youtube.com/watch?v=4fiDs7CCxkc https://leetcode.com/problems/largest-bst-sub 阅读全文

posted @ 2018-08-09 17:11 猪猪🐷

114. Flatten Binary Tree to Linked List
摘要:Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: The flattened tree should look like: 阅读全文

posted @ 2018-08-09 17:04 猪猪🐷

导航