我的解决方式:1 def checkio(data):2 alist = []3 for i in data:4 if (data.count(i) >1 ):5 alist.append(i)6 7 return a...
分类:
其他好文 时间:
2015-04-09 19:10:16
阅读次数:
119
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Hide TagsTreeDepth-first Search方法一:递归,也是dfs/** * Defi...
分类:
其他好文 时间:
2015-04-09 17:08:07
阅读次数:
105
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.Hide TagsDepth-first SearchLinked List方法一...
分类:
其他好文 时间:
2015-04-09 16:50:31
阅读次数:
144
题目:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分析:
将已经排序好的数组转成高度平衡的二叉排序树。
依旧二分法。C++参考代码:/**
* Definition for binary tree
* struct TreeNode {...
分类:
其他好文 时间:
2015-04-09 13:51:49
阅读次数:
112
Rotate Array
Rotate an array of n elements to the right by k steps.
For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is
rotated to [5,6,7,1,2,3,4].
Note:
Try to come up as ma...
分类:
其他好文 时间:
2015-04-08 16:32:21
阅读次数:
97
Given two sorted integer arrays A and B, merge B into A as one sorted array.
Note:
You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from ...
分类:
编程语言 时间:
2015-04-08 15:04:58
阅读次数:
152
题目链接:Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not ...
分类:
其他好文 时间:
2015-04-07 23:33:25
阅读次数:
156
Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri...
分类:
其他好文 时间:
2015-04-07 22:57:47
阅读次数:
106
Given a set of distinct integers, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.
For exa...
分类:
其他好文 时间:
2015-04-07 21:38:13
阅读次数:
138
Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],...
分类:
其他好文 时间:
2015-04-07 21:25:43
阅读次数:
116