MapReduce源码分析之MapTask详解的后半段文章。在分析过程中我们知道了MapTask是如何使用循环缓存区管理数据,知道了数据在缓存不下是如何做spill处理的,spill输出的数据格式,combiner如何处理,如何将多一个文件merge为一个等等。也希望通过阅读这部分源码能学习到部分设计思路,能在未来的设计中提供多一种思路。...
分类:
其他好文 时间:
2014-08-05 00:47:18
阅读次数:
484
Follow up for "Remove Duplicates": What if duplicates are allowed at most twice?For example, Given sorted array A = [1,1,1,2,2,3],Your function should...
分类:
其他好文 时间:
2014-08-05 00:24:38
阅读次数:
281
思路:类似归并排序算法,在合并已经有序的相邻子数组的时候,计算前面数组相对于后面数组的逆序对数,整个递归过程可以算出所有逆序对#include void merge(int A[], int front, int middle, int end, int &count){ if (front ...
分类:
其他好文 时间:
2014-08-04 21:26:48
阅读次数:
262
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.方法:为了使BST高度平衡,要找链表中的中值作为当前根节点。/** * Defin...
分类:
其他好文 时间:
2014-08-04 20:37:47
阅读次数:
194
转载自:http://blog.csdn.net/qinjienj/article/details/7621887我们难免会因为种种原因执行一些错误的commit / push,git提供了revert命令帮助程序员修复这样的错误。举个例子,下图是git commit 的历史记录git rever...
分类:
其他好文 时间:
2014-08-04 14:15:07
阅读次数:
301
题目:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function shou....
分类:
编程语言 时间:
2014-08-04 13:24:27
阅读次数:
256
问题:将有序的数组中重复的数字去掉分析:由于有序所以只用和前一个比较就行class Solution {public: int removeDuplicates(int A[], int n) { int i,j; if(n==0 || n==1) return n...
分类:
其他好文 时间:
2014-08-03 17:42:35
阅读次数:
204
Corner cases!class Solution {public: ListNode *deleteDuplicates(ListNode *head) { if (!head) return head; if (!head->next) return hea...
分类:
其他好文 时间:
2014-08-03 07:51:34
阅读次数:
237
题目再现
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time
complexity should be O(log (m+n)).
题意解析...
分类:
其他好文 时间:
2014-08-02 18:24:13
阅读次数:
335
问题:有序合并两个有序链表分析:归并排序的合并部分class Solution {public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { ListNode *helper=new ListNode(0); ...
分类:
其他好文 时间:
2014-08-02 18:17:03
阅读次数:
170