摘要: Sort a linked list inO(nlogn) time using constant space complexity.归并排序!用慢指针、快指针来寻找二分位置,这里很容易出现错,要特别注意。 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 8 */ 9 class Solution {10 ... 阅读全文
posted @ 2014-04-08 14:00 Eason Liu 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文
posted @ 2014-04-08 13:34 Eason Liu 阅读(290) 评论(0) 推荐(0) 编辑