2016年4月24日

Merge k Sorted Lists

摘要: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 这是一道hard的题目,但是其实思路并不复杂,做起来也比较有趣。做完Merge Two Sorted 阅读全文

posted @ 2016-04-24 16:36 Sheryl Wang 阅读(155) 评论(0) 推荐(0) 编辑

Kth Largest Element in an Array

摘要: 利用最小堆解决,代码如下: 另外一个是使用快排的partition的方法(可见剑指offer167页),寻找index为k-1的pivot ,原理是 一次partition之后,pivot左边的数都小于等于pivot,右边的数都大于等于pivot,所以pivot左边加pivot形成index个数组中 阅读全文

posted @ 2016-04-24 12:00 Sheryl Wang 阅读(189) 评论(0) 推荐(0) 编辑

Merge Two Sorted Lists

摘要: 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. 这题与Add T 阅读全文

posted @ 2016-04-24 11:34 Sheryl Wang 阅读(137) 评论(0) 推荐(0) 编辑

导航