摘要: Well, an extension of Remove Duplicates from Sorted Array.The program is fairly similar to that in this solution.1 int removeDuplicates(vector& nu... 阅读全文
posted @ 2015-06-09 21:39 jianchao-li 阅读(196) 评论(0) 推荐(0) 编辑
摘要: Well, a medium problem. Use two pointers. One points to the curren number and the other points to the last unique number. Once duplicates occur, move ... 阅读全文
posted @ 2015-06-09 21:30 jianchao-li 阅读(172) 评论(0) 推荐(0) 编辑
摘要: Radix sort is another linear time sorting algorithm. It sorts (using another sorting subroutine) the numbers from their least significant digits to mo... 阅读全文
posted @ 2015-06-09 20:48 jianchao-li 阅读(289) 评论(0) 推荐(0) 编辑
摘要: Well, this problem is designed for radix sort. For more information about radix sort, Introduction to Algorithms, 3rd edition has some nice examples.H... 阅读全文
posted @ 2015-06-09 17:13 jianchao-li 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Counting sort is a linear time sorting algorithm. It is used when all the numbers fall in a fixed range. Then it counts the appearances of each number... 阅读全文
posted @ 2015-06-09 15:44 jianchao-li 阅读(263) 评论(0) 推荐(0) 编辑
摘要: The hints on below the problem have suggested a two-pass solution.Now I will focus on the one-pass solution.The one-pass solution has no mystery. Just... 阅读全文
posted @ 2015-06-09 14:31 jianchao-li 阅读(196) 评论(0) 推荐(0) 编辑
摘要: This problem gets much trickier than Contains Duplicate and Contains Duplicate II.The basic idea is to maintain a window of k numbers. For each new nu... 阅读全文
posted @ 2015-06-09 11:18 jianchao-li 阅读(259) 评论(0) 推荐(0) 编辑
摘要: A classic problem of hash set. The unordered_set of C++ is very suitable for this problem.The code is as follows and it should be quite self-explanato... 阅读全文
posted @ 2015-06-09 11:01 jianchao-li 阅读(178) 评论(0) 推荐(0) 编辑