如果for循环完整结束,无break打断循环,那么执行else里面的内容,否则不执行。while True: n = raw_input('>') for x in n: if x == 'f': print 'find it.' ...
分类:
其他好文 时间:
2015-08-08 22:48:52
阅读次数:
119
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest ...
分类:
其他好文 时间:
2015-08-08 21:15:30
阅读次数:
110
题目Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:
Elements in a qu...
分类:
其他好文 时间:
2015-08-08 20:01:47
阅读次数:
111
Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol...
分类:
其他好文 时间:
2015-08-08 19:51:17
阅读次数:
105
题目:bobo has a sequence a1,a2,…,an. He is allowed to swap twoadjacentnumbers for no more than k times.Find the minimum number of inversions after his s...
分类:
编程语言 时间:
2015-08-08 19:46:37
阅读次数:
133
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ...
分类:
其他好文 时间:
2015-08-08 19:42:01
阅读次数:
100
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined
between two node...
分类:
其他好文 时间:
2015-08-08 18:18:38
阅读次数:
110
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined
betw...
分类:
其他好文 时间:
2015-08-08 18:16:58
阅读次数:
132
Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota...
分类:
其他好文 时间:
2015-08-08 17:49:17
阅读次数:
121
Descriptionbobo has a sequence a 1,a 2,…,a n. He is allowed to swap two adjacent numbers for no more than k times. Find the minimum number of inversio...
分类:
其他好文 时间:
2015-08-08 16:29:05
阅读次数:
151