码迷,mamicode.com
首页 >  
搜索关键字:traversal    ( 1649个结果
0987. Vertical Order Traversal of a Binary Tree (M)
Vertical Order Traversal of a Binary Tree (M) 题目 Given a binary tree, return the vertical order traversal of its nodes values. For each node at positi ...
分类:其他好文   时间:2020-08-08 17:30:42    阅读次数:51
二叉树的中序遍历
题目描述: 给定一个二叉树,返回它的中序 遍历。 输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,3,2] //go //* Definition for a binary tree node. type TreeNode struct { Val int Left *TreeN ...
分类:其他好文   时间:2020-08-06 09:31:39    阅读次数:66
leetcode7:binary-tree-preorder-traversal
题目描述 求给定的二叉树的前序遍历。 例如: 给定的二叉树为{1,#,2,3}, 1 \ 2 / 3 返回:[1,2,3]. 备注;用递归来解这道题太没有新意了,可以给出迭代的解法么? /** * struct TreeNode { * int val; * struct TreeNode *lef ...
分类:其他好文   时间:2020-08-05 13:09:09    阅读次数:71
1020 Tree Traversals (25分)
题干 Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ...
分类:其他好文   时间:2020-07-29 21:34:20    阅读次数:77
LC1008 Construct Binary Search Tree from Preorder Traversal
根据BST的前序遍历重建BST 1. 平均O(NlogN) 最坏O(N^2) class Solution { public: TreeNode* dfs(int l, int r, vector<int>& p) { if (l > r) return nullptr; TreeNode* nod ...
分类:其他好文   时间:2020-07-23 16:13:09    阅读次数:67
03-树3 Tree Traversals Again (25分)
03-树3 Tree Traversals Again (25分) An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that w ...
分类:其他好文   时间:2020-07-19 23:08:36    阅读次数:84
leetcode-----94. 二叉树的中序遍历
链接:https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo ...
分类:其他好文   时间:2020-07-18 11:34:31    阅读次数:66
LeetCode 590 N叉树的后序遍历
题目链接:https://leetcode-cn.com/problems/n-ary-tree-postorder-traversal/ 方法一递归法:先访问子节点,然后访问根。LeetCode代码: /* // Definition for a Node. class Node { public ...
分类:其他好文   时间:2020-07-16 21:39:10    阅读次数:79
LeetCode94二叉树中序遍历
题目链接 https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ 题解一:递归 // Problem: LeetCode 94 // URL: https://leetcode-cn.com/problems/binary-tr ...
分类:其他好文   时间:2020-07-13 15:36:49    阅读次数:58
1649条   上一页 1 2 3 4 5 ... 165 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!