Yosgi
Yosgi
Avatar
😀
28 results for Binary Tree
  • The first thing I thought of was to construct a binary tree, and then use the symmetric relationship of each layer to find the parent node var pathInZigZagTree = function(label) { let stack = [] for …
    Algorithms Created Thu, 29 Jul 2021 00:00:00 +1200
  • Time: 60 minutes I was misled by the depth of the question and thought that the calculation depth should be done from top to bottom. In fact, it can be done from bottom to top. If the left and right …
    Algorithms Created Sun, 21 Mar 2021 00:00:00 +1300
  • Time: 10 minutes Solve by using the property of pre-order traversal of binary tree var minDiffInBST = function(root) { var min = Infinity var pre = null var dfs = function (root) { if (!root) return …
    Algorithms Created Thu, 18 Mar 2021 00:00:00 +1300
  • Time: 10 minutes The preorder is calculated from top to bottom, there is nothing much to say Converting binary to decimal is quite difficult, so I just parseInt(path, 2) var sumRootToLeaf = …
    Algorithms Created Wed, 17 Mar 2021 00:00:00 +1300
  • Post-order traversal approach to delete target-valued leaf nodes using a dummy root.
    Algorithms Created Wed, 17 Mar 2021 00:00:00 +1300
  • Notes on counting good nodes in a binary tree using DFS with a running max.
    Algorithms Created Wed, 17 Mar 2021 00:00:00 +1300
  • Time: 6 minutes It’s very simple. In-order traversal, calculate whether the value 1 exists in the subtrees on both sides, and remove it if not. If the left or right subtree or the tree itself contains …
    Algorithms Created Wed, 17 Mar 2021 00:00:00 +1300
  • The question is about starting from the root node. The first thing that comes to mind is top-down DFS, passing parameters downward, and the end condition has no left or right children. Start with the …
    Algorithms Created Tue, 16 Mar 2021 00:00:00 +1300
  • Time: 15 minutes Time: 15 minutes My first reaction when I got the question was to use recursion, but after I started writing it, I found that The condition that recursion needs to meet is that the …
    Algorithms Created Tue, 16 Mar 2021 00:00:00 +1300
  • Time: 30 minutes Once you understand the question, you can actually do it quickly. The question is about the value of any node. We can find the value of each node and choose the largest one. Since the …
    Algorithms Created Mon, 15 Mar 2021 00:00:00 +1300
Next