码迷,mamicode.com
首页 >  
搜索关键字:beginners problems    ( 6414个结果
[leetcode]Balanced Binary Tree @ Python
原题地址:http://oj.leetcode.com/problems/balanced-binary-tree/题意:判断一颗二叉树是否是平衡二叉树。解题思路:在这道题里,平衡二叉树的定义是二叉树的任意节点的两颗子树之间的高度差小于等于1。这实际上是AVL树的定义。首先要写一个计算二叉树高度的函...
分类:编程语言   时间:2014-05-12 14:51:47    阅读次数:304
[leetcode]Construct Binary Tree from Preorder and Inorder Traversal @ Python
原题地址:http://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/题意:根据二叉树的先序遍历和中序遍历恢复二叉树。解题思路:可以参照http://www.cnblogs.com...
分类:编程语言   时间:2014-05-12 14:24:57    阅读次数:324
[leetcode]Construct Binary Tree from Inorder and Postorder Traversal @ Python
原题地址:http://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/题意:根据二叉树的中序遍历和后序遍历恢复二叉树。解题思路:看到树首先想到要用递归来解题。以这道题为例:如果一...
分类:编程语言   时间:2014-05-12 14:09:28    阅读次数:321
[leetcode]Binary Tree Inorder Traversal @ Python
原题地址:http://oj.leetcode.com/problems/binary-tree-inorder-traversal/题意:二叉树的中序遍历。解题思路:这道题用递归解不难,所以应该考察的是非递归求解二叉树的中序遍历。我们使用一个栈来解决问题。比如一颗二叉树为{1,2,3,4,5,6,...
分类:编程语言   时间:2014-05-12 12:48:36    阅读次数:316
[leetcode]Binary Tree Preorder Traversal @ Python
原题地址:http://oj.leetcode.com/problems/binary-tree-preorder-traversal/题意:这题用递归比较简单。应该考察的是使用非递归实现二叉树的先序遍历。解题思路:使用一个栈。先遍历节点,然后将这个节点入栈,如果这个节点的左孩子非空,遍历左孩子,然...
分类:编程语言   时间:2014-05-12 12:09:39    阅读次数:327
POJ 2151 Check the difficulty of problems (概率dp)
题意:给出m、t、n,接着给出t行m列,表示第i个队伍解决第j题的概率。 现在让你求:每个队伍都至少解出1题,且解出题目最多的队伍至少要解出n道题的概率是多少?思路:求补集。 即所有队伍都解出题目的概率,减去所有队伍解出的题数在1~n-1之间的概率这里关键是如何求出某个队伍解出的...
分类:其他好文   时间:2014-05-10 22:21:45    阅读次数:318
UVA-1401-Remember the Word(Trie)
Neal is very curious about combinatorial problems, and now here comes a problem about words. Knowing that Ray has a photographic memory and this may not trouble him, Neal gives it to Jiejie. Since Ji...
分类:其他好文   时间:2014-05-10 03:48:22    阅读次数:352
[leetcode]Single Number II @ Python
原题地址:http://oj.leetcode.com/problems/single-number-ii/题意:Given an array of integers, every element appearsthreetimes except for one. Find that single ...
分类:编程语言   时间:2014-05-10 03:01:41    阅读次数:413
Edit Distance @Leetcode -- Python
http://oj.leetcode.com/problems/edit-distance/class Solution: # @return an integer def minDistance(self, word1, word2): len1 = len(word1)...
分类:编程语言   时间:2014-05-09 04:19:03    阅读次数:407
Longest Valid Parentheses @Leetcode -- Python
http://oj.leetcode.com/problems/longest-valid-parentheses/ 1 class Solution: 2 # @param s, a string 3 # @return an integer 4 def longestVa...
分类:编程语言   时间:2014-05-09 00:11:38    阅读次数:410
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!