This is a quick recap on different elementary sorting including Bubble Sort, Selection Sort, Insertion Sort, Shell Sort, the main point here is to review them and explain why are we interested in each of them.

Read More
Analysis and implementations (in linear time) are given to determine whether or not a pop sequence of stack is possible given a specific push sequence.

Read More
I give a recursive implementation for K sum, so any K Sum Problems (2sum, 3sum, 4sum, etc) could be solved by the same code in a consistent way. And the lower bound Ω(n^ceil(k/2)) of the K sum problem is also given here just for your information, which is quite theoretical and research oriented.

Read More
I implemented and discussed the common approach which reduces 4sum to 3sum and then to 2sum with O(N^3) time. The hash based approach is also analyzed too and sophysicated details about implementation are given. Time complexity differs depending on the type of hash map we use, O(N^2logN) for tree ordered hash map, O(N^2) for unordered hash map.

Read More
We discuss 3Sum Closest problem the solution to which turns out to be simplified in less than 20 lines and sorting method is adopted. One could treat this problem as a simple extended exercise for the 3sum problem.

Read More