这道题虽然简单,但是需要注意的点还是比较多,首先是如果一直有重复的duplicate,要把所有的都去掉,所以inner loop是while而不是if,其次是每一层loop结束的条件,要搞清楚是head,还是head.next是不是None。 最后学习一下在python中如何建立一个class并且写 ...
分类:
其他好文 时间:
2020-01-26 10:31:56
阅读次数:
69
采用希尔排序 1 #include <stdio.h> 2 3 #define MAXN 10 4 typedef float ElementType; 5 6 ElementType Median( ElementType A[], int N ); 7 8 int main () 9 { 10 ...
分类:
其他好文 时间:
2020-01-26 10:30:52
阅读次数:
166
1 class Solution: 2 def arrayRankTransform(self, arr: List[int]) -> List[int]: 3 n = len(arr) 4 if n == 0: 5 return [] 6 sortlist = sorted(arr) 7 dic ...
分类:
其他好文 时间:
2020-01-26 10:15:40
阅读次数:
97
一、题目 Median of Two Sorted Arrays,具体请自行搜索。 这个题目,我看了一下,经过一番思考,我觉得实现起来不是很复杂。 但要做到bug free也不难,最大的问题是性能问题。 性能只有42%的样子,内存占用太多。还需要进一步优化!!! 二、这个题目,我自己实现 提交了2次 ...
分类:
其他好文 时间:
2020-01-25 10:19:29
阅读次数:
82
题意 $n$段区间,要把他们分到两个不同的集合$S,T$中,不能有剩余,每个区间只能在一个集合里,令$S$中所有区间的交的长度为$ls$,$T$中所有区间的交为$lt$,求$max\{ls+lt\}$。 题解 找到 $L$ 最大的区间 $p$ 和 $r$ 最小的区间 $q$,那么只有两种情况: $1 ...
分类:
其他好文 时间:
2020-01-24 18:40:19
阅读次数:
63
Introduction We have discussed in a previous article, in most common situation if we have to maintain two Arrays working consistantly, we should bette ...
分类:
其他好文 时间:
2020-01-24 13:16:42
阅读次数:
79
原题链接在这里:https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list/ 题目: Given a node from a Circular Linked List which is sorted in ascen ...
分类:
其他好文 时间:
2020-01-24 12:07:34
阅读次数:
87
Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defi ...
分类:
其他好文 时间:
2020-01-24 10:50:25
阅读次数:
98
You have some sticks with positive integer lengths. You can connect any two sticks of lengths X and Y into one stick by paying a cost of X + Y. You pe ...
分类:
其他好文 时间:
2020-01-24 09:32:12
阅读次数:
90
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 ...
分类:
其他好文 时间:
2020-01-23 22:59:05
阅读次数:
154