文章 2021-12-03 来自:开发者社区

【leetcode刷题】22.二叉树的中序遍历——Java版

前言哈喽,大家好,我是一条。糊涂算法,难得糊涂今天工作中刚好遇到部门下拉树,那就做一道中序遍历吧!Question94. 二叉树的中序遍历难度:简单给定一个二叉树的根节点 root ,返回它的 中序 遍历。示例 1:输入:root = [1,null,2,3] 输出:[1,3,2]示例2:输入:root = [] 输出:[]示例3:输入:root = [1] 输出:[1]示例4:输入:root ....

【leetcode刷题】22.二叉树的中序遍历——Java版
文章 2019-08-20 来自:开发者社区

LeetCode 94:二叉树的中序遍历 Binary Tree Inorder Traversal

题目: 给定一个二叉树,返回它的中序 遍历。 Given a binary tree, return the inorder traversal of its nodes' values. 示例: 输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,3,2] 进阶: 递归算法很简单,你可以通过迭代算法完成吗? Follow up: Recu...

文章 2019-06-05 来自:开发者社区

Leetcode 498:对角线遍历Diagonal Traverse(python3、java)

对角线遍历 给定一个含有 M x N 个元素的矩阵(M 行,N 列),请以对角线遍历的顺序返回这个矩阵中的所有元素,对角线遍历如下图所示。Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below im....

文章 2018-05-18 来自:开发者社区

leetcode算法题解(Java版)-12-中序遍历

日子又恢复正常了,浪了半个月。。。还是学习的时候感觉好~~ 一、动态规划 题目描述 Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST's. 1...

文章 2018-04-27 来自:开发者社区

leetcode算法题解(Java版)-1-二叉树遍历

又开始刷算法题了,正好在学Java,顺便也练练Java。 题目描述 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 alternate betwe....

文章 2017-12-10 来自:开发者社区

[LeetCode] Diagonal Traverse 对角线遍历

Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Out...

[LeetCode] Diagonal Traverse 对角线遍历
文章 2017-12-04 来自:开发者社区

[LeetCode] Binary Tree Postorder Traversal 二叉树的后序遍历

Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Recursive solution is trivi...

文章 2017-12-04 来自:开发者社区

[LeetCode] Construct Binary Tree from Inorder and Postorder Traversal 由中序和后序遍历建立二叉树

Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. 这道题要求从中序和后序遍历的结果来重建原二叉树,我们知道中序的遍历顺序是左-根-右,后序的顺序是左-右-根,对于这种树的....

文章 2017-12-03 来自:开发者社区

[LeetCode] Construct Binary Tree from Preorder and Inorder Traversal 由先序和中序遍历建立二叉树

Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. 这道题要求用先序和中序遍历来建立二叉树,跟之前那道Construct Binary Tree from Inorder a....

文章 2017-12-03 来自:开发者社区

[LeetCode] Binary Tree Inorder Traversal 二叉树的中序遍历

Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note: Recursive solution is trivial...

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。

算法编程

开发者社区在线编程频道官方技术圈。包含算法资源更新,周赛动态,每日一题互动。

+关注