Sort a linked list in O(n log n) time using constant space complexity. 链表,快慢指针找中点,归并排序。 注意判断条件fast->next!=NULL&&fast->next->next!=NULL,若为fast!=NULL&&f ...
分类:
编程语言 时间:
2017-06-07 12:34:02
阅读次数:
172
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh ...
分类:
编程语言 时间:
2017-06-04 00:16:34
阅读次数:
232
This is an easy question. No matter what kind of method you chose, the time complexity is at least O(m*n), becasue you have to traverse each element a ...
分类:
其他好文 时间:
2017-06-03 09:49:10
阅读次数:
292
https://leetcode.com/problems/k-diff-pairs-in-an-array/#/description This is a very simple question. With two-pointer method, the time complexity is O ...
分类:
其他好文 时间:
2017-05-31 10:21:51
阅读次数:
131
Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a functi ...
分类:
编程语言 时间:
2017-05-25 11:55:11
阅读次数:
153
题目描述 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 shoul ...
分类:
编程语言 时间:
2017-05-24 22:42:59
阅读次数:
292
problem: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Tags Divide and Conquer Linked List Heap 合 ...
分类:
其他好文 时间:
2017-05-16 15:49:50
阅读次数:
236
https://en.wikipedia.org/wiki/Sorting_algorithm Computational complexity theory Big O notation Total order Lists Inplacement Stability Comparison sort ...
分类:
编程语言 时间:
2017-05-14 13:42:24
阅读次数:
164
题目: Sort a linked list in O(n log n) time using constant space complexity. Example Given 1->3->2->null, sort it to 1->2->3->null. Given 1->3->2->null, ...
分类:
其他好文 时间:
2017-05-13 11:10:13
阅读次数:
155
一、常见的时间复杂度 常见时间复杂度的比较 二、算法分析 定义一个数组 此算法最好的情况时执行一次 而最坏的情况却要执行n次 注意:数据结构课程中,在没有特殊说明时,所分析算法的时间复杂度都是指最坏时间复杂度 三、算法的空间复杂度(space complexity) (1)、定义:S(n) = S( ...
分类:
编程语言 时间:
2017-05-03 22:01:10
阅读次数:
214