## Solution to Maximum Gap by LeetCode

6 Apr

Question: https://leetcode.com/problems/maximum-gap/ Question Name: Maximum Gap The solution uses the bucket sorting and Pigeonhole principle. We divide the input range into bucketCount ranges. Each sub-section has the same length, and the sum of all the sub-sections covers the whole input … Read More »

## Partial Missing Code in Comments of WordPress

10 Mar

Sometimes, the visitors posted their code in the comment section. That is an awesome way to share and communicate. However, in some cases, partial of the code inside pre/code section is missing. This unexpected feature bothered me for a long … Read More »

## Solution to Combine Two Tables by LeetCode

28 Feb

Question: https://oj.leetcode.com/problems/combine-two-tables/ Question Name: Combine Two Tables This problem is used to check our knowledge in JOIN. LEFT JOIN is used here. But we should also know about the others like INNER JOIN, RIGHT JOIN and OUTER JOIN.

## Solution to Find Peak Element by LeetCode

26 Dec

Question: https://oj.leetcode.com/problems/find-peak-element/ Question Name: Find Peak Element The key point is: return the index to ANY ONE of the peaks. So O(logN) is possible.

25 Dec

## Solution to Min Stack by LeetCode

21 Dec

Question: https://oj.leetcode.com/problems/min-stack/ Question Name: Min Stack

## Solution to Find Minimum in Rotated Sorted Array II by LeetCode

21 Dec

Question: https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/ Question Name: Find Minimum in Rotated Sorted Array II This question is essentially the same as the prevous one.

## Solution to Find Minimum in Rotated Sorted Array by LeetCode

20 Oct

Question: https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array/ Question Name: Find Minimum in Rotated Sorted Array

## Solution to Maximum Product Subarray by LeetCode

29 Sep

Question: https://oj.leetcode.com/problems/maximum-product-subarray/ Question Name: Maximum Product Subarray The following solution is not the optimal. Because the recursion is not necessary. But recursion does make the coding easier.

## Solution to Lowest Common Ancestor from Jobdu

14 Sep

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1509 Question Name: Lowest Common Ancestor Question Description: Find the lowest common ancestor of two nodes in a binary tree. Input: the input might contain multiple test cases. Globally the first line includes one interger N (0 … Read More »