上一页 1 2 3 4 5 6 7 8 ··· 13 下一页
摘要: partition函数是快排的核心部分它的目的就是将数组划分为pivot两部分,或者是=pivot其实现方法大体有两种,单向扫描版本和双向扫描版本,但是具体到某个版本,其实现方法也是千差万别,参差不齐。本着严谨治学的态度,我将目前所接触的所有实现列举出来,并作出比较。除了伪代码,我也会给出相应的C&... 阅读全文
posted @ 2016-01-14 22:12 sdlwlxf 阅读(8374) 评论(1) 推荐(3) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Note:Do not modify the linked list.Follow up:Can you sol... 阅读全文
posted @ 2016-01-13 20:55 sdlwlxf 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cas... 阅读全文
posted @ 2016-01-13 19:40 sdlwlxf 阅读(118) 评论(0) 推荐(0) 编辑
摘要: Implement pow(x,n).Subscribeto see which companies asked this question利用依次消去二进制位上的1,来进行计算double myPow(double x, int n) { double ans = 1; unsigne... 阅读全文
posted @ 2016-01-13 13:36 sdlwlxf 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文
posted @ 2016-01-11 22:20 sdlwlxf 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文
posted @ 2016-01-11 21:17 sdlwlxf 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 再次优化快速排序,三数中值取理想的pivot,三向切分忽略与pivot相同的元素,小数组转插入排序(唯一不足递归实现,不过是尾递归,编译器可以优化掉)代码很短,而且可读性很好,记录于此以供参考const int cutoff = 3;void insertSort(int a[], int len)... 阅读全文
posted @ 2016-01-11 14:27 sdlwlxf 阅读(703) 评论(0) 推荐(0) 编辑
摘要: void insertSort(int a[], int len){ for (int i = 1; i = 0; --j) { if (a[j] > 1; if (a[left] > a[center]) swap(&a[left], ... 阅读全文
posted @ 2016-01-11 11:03 sdlwlxf 阅读(348) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the differe... 阅读全文
posted @ 2016-01-09 16:28 sdlwlxf 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr... 阅读全文
posted @ 2016-01-09 16:21 sdlwlxf 阅读(105) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 13 下一页