ICode9

精准搜索请尝试: 精确搜索
  • 105. Construct Binary Tree from Preorder and Inorder Traversal2019-03-15 14:42:00

    Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 见剑指offer重建二叉树 class Solution {     public TreeNode buildTree(int[] preorder, int[] inorder) {        

  • Tree——No.94 Binary Tree Inorder Traversal2019-03-10 17:54:22

    Problem: Given a binary tree, return the inorder traversal of its nodes' values. Explanation: 中序遍历给定二叉树 My Thinking: 使用常规递归进行中序遍历,不过这里需要添加一个函数,才能将结果列表作为参数传递。 My Solution: class Solution { public List<Integer> in

  • LeetCode题解之 Increasing Order Search Tree2019-02-24 14:44:48

    1、题目描述 2/问题分析 利用中序遍历,然后重新构造树。   3、代码 1 TreeNode* increasingBST(TreeNode* root) { 2 if (root == NULL) 3 return NULL; 4 vector<int> v; 5 inorder(root,v); 6 7 TreeNode* dummy

  • LeetCode 94 二叉树的中序遍历2019-02-23 11:53:53

    题目: https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/ 题意: 给定一个二叉树,返回它的中序 遍历。 思路: 经典题目了,递归版和非递归版,时间复杂度均为O(n)O(n)O(n) 代码: 递归版: class Solution { public: vector<int> inorderTraversal(TreeNode* root

  • 04-树6 Complete Binary Search Tree (30 分)2019-02-20 21:38:44

    A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:   The left subtree of a node contains only nodes with keys less than the node's key.     The right subtree of a node contains only nodes with key

  • 【leetcode】501. Find Mode in Binary Search Tree2019-02-15 17:01:32

    class Solution { public: vector<int> modes; int maxCnt = 0; int curCnt = 0; int curNum = 0; vector<int> findMode(TreeNode* root) { if (!root) { return modes; } curNum = root->val;

  • [Lintcode]73. Construct Binary Tree from Preorder and Inorder Traversal/[Leetcode]2019-02-14 21:49:33

    73. Construct Binary Tree from Preorder and Inorder Traversal/ 本题难度: Medium Topic: Binary Tree Description Given preorder and inorder traversal of a tree, construct the binary tree. Example Example 1: Input: [], [] Output: null Example 2: Input: in-orde

  • LeetCode-105-Construct Binary Tree from Preorder and Inorder Traversal2019-02-03 08:52:30

    算法描述: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For example, given preorder = [3,9,20,15,7] inorder = [9,3,15,20,7] Return the following binary tree: 3 /

  • LeetCode-106-Construct Binary Tree from Inorder and Postorder Traversal2019-02-03 08:51:27

    算法描述: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For example, given inorder = [9,3,15,20,7] postorder = [9,15,7,20,3] Return the following binary tree: 3

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有