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.
Merge Policies in Solr
I happened to get an chance to optimize the Solr configuration of Home Depot Canada. My mainly improvement is focused on the segments merge policies. However there are limited resources on-line, I spent some time looking into the source code of LogMergePolicy and TieredMergePolicy. I am going to share how does these two mostly used Solr merge polices work and my findings.
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.