Home

Find the Largest K Elements

Find the largest K element in an array is a common code challenge in interviews. You may see this problem in several different formats like K Closest Points to the Origin.

Sorting the whole given array can solve this problem in time complexity of \(O(n\,log\,n)\) and space complexity of \(O(n)\). However, there is another efficient solution, which has a huge improvement of space complexity when K is small, through an import data structure - Heap.

Read more

Maximum Subarray Problem

Maximum subarray is a typical interview question you may face. Its description can be found here.

There are two common approaches to solve this problem, dynamic programing(\(O(n)\)) and divide and conquer(\(O(n\,log\,n)\)). I am going to share the solutions and thoughts of them in this article.

Read more