原创 Maximum Gap

Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solv

原创 Course Schedule

There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for

原创 Course schedule II

和course schedule一樣的要求,只是要求輸出toplogicl排序的結果。一個tricky的地方就是如果沒有正常結果,輸出new int[0 public class Solution { public int[] f

原创 Minimum size subarray sum

iven an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum

原创 Producer Consumer problem - mutex and semaphore

很典型的一道多線程題目。如果使用BlockingQueue,就十分簡單。但是要注意blockingqueue的語法,用put/take package concurrent; import java.util.concurrent.Bl

原创 Dungeon Gam

The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon cons

原创 Lintcode - Convert Expression to Polish Notation

Given an expression string array, return the Polish notation of this expression. (remove the parentheses) Example F

原创 Lintcode - Convert Expression to Reverse Polish Notation

Given an expression string array, return the Reverse Polish notation of this expression. (remove the parentheses) Ex

原创 Lintcode - Expression Evaluation

Given an expression string array, return the final result of this expression Example For the expression 2*6-(23+7)

原创 Repeated DNA Sequences

All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studyin

原创 Lintcode - Segment Tree Query

For an integer array (index from 0 to n-1, where n is the size of this array), in the corresponding SegmentTree, each

原创 Binary Tree Right Side View

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see or

原创 Save BST to a file

http://articles.leetcode.com/2010/09/saving-binary-search-tree-to-file.html preorder traversal將bst存下來。 如何恢復?依然preorder

原创 Lintcode - Segment Tree Modify

For a Maximum Segment Tree, which each node has an extra value max to store the maximum value in this node's interval

原创 Find Peak Element

A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find