Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree {3,9,...
分类:
其他好文 时间:
2015-05-16 20:35:48
阅读次数:
155
题目: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 onl...
分类:
其他好文 时间:
2015-05-16 20:21:48
阅读次数:
91
1 /*************************** 2 https://leetcode.com/problems/binary-tree-preorder-traversal/ 3 @date 2015.5.13 4 @description 5 用非递归方法对二叉树进行先序...
分类:
其他好文 时间:
2015-05-16 18:19:07
阅读次数:
97
1 /************************** 2 https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 3 @date 2015.5.16 4 @descrip....
分类:
其他好文 时间:
2015-05-16 18:16:24
阅读次数:
167
https://leetcode.com/problems/maximum-depth-of-binary-tree/Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth i...
分类:
编程语言 时间:
2015-05-16 18:11:43
阅读次数:
124
https://leetcode.com/problems/same-tree/Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are consi...
分类:
编程语言 时间:
2015-05-16 18:07:57
阅读次数:
130
题目:Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 ...
分类:
其他好文 时间:
2015-05-16 17:57:57
阅读次数:
107
题意:题意比较简单就是二叉树的中序遍历
思路:1. 递归是最简单的了
2. 非递归的实现:用一个stack做存储结构
一直查找leftchild 知道没有下一个leftchild,访问该元素
如果该元素有right child 加入stack
从stack中取出一个元素 重复上述行为(这里需要加入set集合记录访问过得left的节点 否则会出现重复访问的问题)
代码:
...
分类:
其他好文 时间:
2015-05-16 16:34:34
阅读次数:
100
题目:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. ...
分类:
其他好文 时间:
2015-05-16 16:23:31
阅读次数:
92
Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100".解题思路:JAVA实现如下:static public String addBinar...
分类:
编程语言 时间:
2015-05-16 13:16:18
阅读次数:
172