不留: [抄题]: 给定一个排序链表,删除所有重复的元素只留下原链表中没有重复的元素。 [思维问题]: [一句话思路]: [输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入): [画图]: [一刷]: [总结]: [复杂度]:Time complexity: ...
分类:
其他好文 时间:
2017-12-22 22:51:34
阅读次数:
117
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 function ...
分类:
其他好文 时间:
2017-12-13 11:34:37
阅读次数:
145
题目: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题意:合并k个有序链表,分析和描述它的时间复杂度。 代码过来: 上面就是我对这道题的解析,其实 ...
分类:
其他好文 时间:
2017-12-11 21:11:05
阅读次数:
141
题目: Sort a linked list in O(n log n) time using constant space complexity. 题意:对一个单链表进行排序操作,要求时间复杂度为 O(n log n),看到这里很明显想到的是归并排序,直接上代码: 这道题解决起来并不难,在其中的难 ...
分类:
其他好文 时间:
2017-12-11 20:05:48
阅读次数:
119
148. Sort List 题目:Sort a linked list in O(n log n) time using constant space complexity. 题意:排序链表 思路I:merge sort 复杂度分析:时间复杂度O(nlgn),空间复杂度O(1) 1 /** 2 * ...
分类:
其他好文 时间:
2017-12-11 16:13:37
阅读次数:
148
Time Complexity: O(N*K), Space Complexity: O(1) The idea is similar to the problem Paint House I, for each house and each color, the minimum cost of p ...
分类:
其他好文 时间:
2017-11-30 13:37:47
阅读次数:
184
//题目:输入一个已经按升序排序过的数组和一个数字,在数组中查找两个数,使得它们的和正好是输入的那个数字。要求时间复杂度是O(n)。考虑多对同时满足的情况例如输入数组1、2、4、7、11、15和数字15。由于4+11=15,因此输出4和11。代码function time_complexity($a ...
分类:
编程语言 时间:
2017-11-13 23:04:14
阅读次数:
190
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-11-11 17:40:11
阅读次数:
81
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBECOD ...
Backtracking: time complexity O(N!) Use HashMap to store the initial debts of each person, negative means the person sends money to others, positive m ...
分类:
其他好文 时间:
2017-11-08 13:17:47
阅读次数:
231