Mew


  • 首页

  • 分类

  • 归档

  • 标签

Leetcode解题-Maximum Depth of Binary Tree

发表于 2015-09-09   |   分类于 编程题   |  
描述 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthes ...
阅读全文 »

Leetcode解题-Minimum Depth of Binary Tree

发表于 2015-09-09   |   分类于 编程题   |  
描述 Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the neares ...
阅读全文 »

Leetcode解题-Convert Sorted List to Binary Search Tree

发表于 2015-09-09   |   分类于 编程题   |  
描述 Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 分析和上一题不同的是,这次是链表,不能随机访问,那么自顶向下的分治法就失 ...
阅读全文 »

Leetcode解题-Convert Sorted Array to Binary Search Tree

发表于 2015-09-09   |   分类于 编程题   |  
描述 Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 分析递归分治法解很容易,时间O(n),空间平均O(logn)。 代码Python12345678 ...
阅读全文 »

Leetcode解题-Validate Binary Search Tree

发表于 2015-09-09   |   分类于 编程题   |  
描述 Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains o ...
阅读全文 »

Leetcode解题-Unique Binary Search Trees II

发表于 2015-09-09   |   分类于 编程题   |  
描述 Given n, generate all structurally unique BST’s (binary search trees) that store values 1…n. For example,Given n = 3, your program should return al ...
阅读全文 »

Leetcode解题-Unique Binary Search Trees

发表于 2015-09-09   |   分类于 编程题   |  
描述 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 ...
阅读全文 »

Leetcode解题-Construct Binary Tree from Inorder and Postorder Traversal

发表于 2015-09-09   |   分类于 编程题   |  
描述 Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 分析上一题的姐妹 ...
阅读全文 »

Leetcode解题-Construct Binary Tree from Preorder and Inorder Traversal

发表于 2015-09-09   |   分类于 编程题   |  
描述 Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 分析经典题,从前序 ...
阅读全文 »

Leetcode解题-Populating Next Right Pointers in Each Node II

发表于 2015-09-09   |   分类于 编程题   |  
描述 Follow up for problem “Populating Next Right Pointers in Each Node”. What if the given tree could be any binary tree? Would your previous solution ...
阅读全文 »

Leetcode解题-Populating Next Right Pointers in Each Node

发表于 2015-09-09   |   分类于 编程题   |  
描述 Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point ...
阅读全文 »

Leetcode解题-Flatten Binary Tree to Linked List

发表于 2015-09-08   |   分类于 编程题   |  
描述 Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look ...
阅读全文 »

Leetcode解题-Balanced Binary Tree

发表于 2015-09-08   |   分类于 编程题   |  
描述 Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the d ...
阅读全文 »

Leetcode解题-Symmetric Tree

发表于 2015-09-08   |   分类于 编程题   |  
描述 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ ...
阅读全文 »

Leetcode解题-Same Tree

发表于 2015-09-08   |   分类于 编程题   |  
描述 Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identica ...
阅读全文 »
«1…567…11»
Garfieldog

Garfieldog

只有猪肉卷是永恒的

158 日志
2 分类
39 标签
RSS
github zhihu
Creative Commons
©   2015 - 2016 Garfieldog
由 Hexo 强力驱动
主题 - NexT