随笔分类 -  tree(bfs)

364. Nested List Weight Sum II
摘要:Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists... 阅读全文

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

107. Binary Tree Level Order Traversal II
摘要:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:
Given binary tree [3,9,20,null,null,15,7... 阅读全文

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

314. Binary Tree Vertical Order Traversal
摘要:use two stacks 阅读全文

posted @ 2018-08-16 23:57 猪猪🐷

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 猪猪🐷

103. Binary Tree Zigzag Level Order Traversal
摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文

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

637 Average of Levels in Binary Tree
摘要:Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: 阅读全文

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

102 Binary Tree Level Order Traversal
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3 阅读全文

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

513. Find Bottom Left Tree Value
摘要:Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Example 2: 阅读全文

posted @ 2018-08-09 16:55 猪猪🐷

404. Sum of Left Leaves
摘要:Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 1 阅读全文

posted @ 2018-08-09 16:51 猪猪🐷

导航