Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * public class TreeN...
分类:
其他好文 时间:
2014-08-30 01:10:48
阅读次数:
333
leetcode上有四道关于移除有序序列中重复数字的题目,其中两道为数组结构,两道为链表结构,分别为:
(1)Remove Duplicates from sorted array I:移除一个有序数组中的重复数字,并且返回新数组的大小。
(2)Remove Duplicates from sorted array II:移除一个有序数组中的重复数字,并且返回新数组的大小,和上道题目不同的是每...
分类:
其他好文 时间:
2014-08-29 18:24:28
阅读次数:
289
题目:
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
解析:合并k个有序链表,最后返回一个总的有序链表,分析并描述其复杂度。该题的实质为归并排序,平均时间复杂度为O(NlogN)。
...
分类:
其他好文 时间:
2014-08-29 11:05:07
阅读次数:
225
python列表排序简单记一下python中List的sort方法(或者sorted内建函数)的用法。关键字:python列表排序 python字典排序 sortedList的元素可以是各种东西,字符串,字典,自己定义的类等。sorted函数用法如下:Python代码sorted(data,cmp=...
分类:
编程语言 时间:
2014-08-29 10:37:57
阅读次数:
240
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.public cl...
分类:
其他好文 时间:
2014-08-29 01:16:36
阅读次数:
267
[ 问题: ]
Given two sorted integer arrays A and B, merge B into A as one sorted array.
直译:给定两个排好序的整形数组,将数组B合并到数组A,形成一个新的有序数组。...
分类:
其他好文 时间:
2014-08-28 14:53:19
阅读次数:
214
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.方法:将有序数组转为平...
分类:
其他好文 时间:
2014-08-27 23:17:18
阅读次数:
278
思想:因为 A 很大, 所以从最大值开始插入, 即从 A 的 m+n 位置开始插入数据。避免了冗余的移动。
思想:
1. 由于要 O(1) 时间确定某 key 是不是在 Cache 中,所以用 Hash_map (), 从而能够O(1)找到结点地址,返回对应的 value。
2. 由...
分类:
其他好文 时间:
2014-08-27 21:43:08
阅读次数:
191