摘要:
Well, it seems that many people meet the TLE problem. Well, I use a simple trick in my code to aoivd TLE. That is, each time before I try to breaks, I... 阅读全文
摘要:
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... 阅读全文
摘要:
Problem Description:Given an array of integers that is alreadysorted in ascending order, find two numbers such that they add up to a specific target n... 阅读全文
摘要:
Again, a classic interview question of linked list. Similar to Linked List Cycle, we maintain two pointers fast and slow: fastmove two steps at one ti... 阅读全文
摘要:
A classic interview question of linked list. The idea is to maintain two pointers, one move one step at a time and the other move two steps at a time.... 阅读全文
摘要:
This problem has a long story. There are just too many solutions on the web and it can be studied for a long time before you fully grasp it. Morever, ... 阅读全文
摘要:
This is a classic problem for hash table. The basic idea is to maintain a hash table for each element innums, using the element as key and its index (... 阅读全文
摘要:
Well, this problem looks easy at first glance. However, to get a bug-free code may be not that easy.The total square is simply equal to the sum of the... 阅读全文