摘要:
Well, an extension of Remove Duplicates from Sorted Array.The program is fairly similar to that in this solution.1 int removeDuplicates(vector& nu... 阅读全文
摘要:
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 ... 阅读全文
摘要:
Radix sort is another linear time sorting algorithm. It sorts (using another sorting subroutine) the numbers from their least significant digits to mo... 阅读全文
摘要:
Well, this problem is designed for radix sort. For more information about radix sort, Introduction to Algorithms, 3rd edition has some nice examples.H... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文
摘要:
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... 阅读全文