Java Algorithm Solutions - LeetCode/LintCode

Java Solutions to algorithm problems from LintCode, LeetCode...etc.

#Problem Level Language
02 Sum II - Input array is sorted.javaJava
12 Sum II.javaJava
22 Sum.javaJava
33 Sum Closest.javaJava
43 Sum.javaJava
53Sum Smaller.javaJava
64 Sum.javaJava
7A+B.javaJava
8Add and Search Word.javaJava
9Add Binary.javaJava
10Add Two Numbers II.javaJava
11Add Two Numbers.javaJava
12Alien Dictionary.javaJava
13Anagrams.javaJava
14Backpack II.javaJava
15Backpack.javaJava
16Balanced Binary Tree.javaJava
17Best Time to Buy and Sell Stock I.javaJava
18Best Time to Buy and Sell Stock II.javaJava
19Best Time to Buy and Sell Stock III .javaJava
20Best Time to Buy and Sell Stock IV.javaJava
21Binary Representation.javaJava
22Binary Search Tree Iterator.javaJava
23Binary Tree Inorder Traversal.javaJava
24Binary Tree Level Order Traversal II.javaJava
25Binary Tree Level Order Traversal.javaJava
26Binary Tree Longest Consecutive Sequence.javaJava
27Binary Tree Maximum Path Sum II.javaJava
28Binary Tree Maximum Path Sum.javaJava
29Binary Tree Path Sum.javaJava
30Binary Tree Paths.javaJava
31Binary Tree Postorder Traversal.javaJava
32Binary Tree Preorder Traversal.javaJava
33Binary Tree Right Side View.javaJava
34Binary Tree Serialization.javaJava
35Binary Tree Zigzag Level Order Traversal.javaJava
36Building Outline.javaJava
37Burst Balloons.javaJava
38Change to Anagram.javaJava
39Classical Binary Search.javaJava
40Climbing Stairs.javaJava
41Clone Graph.javaJava
42Closest Binary Search Tree Value.javaJava
43Closest Number in Sorted Array.javaJava
44Coins in a Line.javaJava
45ColorGrid.javaJava
46Combination Sum II.javaJava
47Combination Sum.javaJava
48Combinations.javaJava
49Compare Strings.javaJava
50Complete Binary Tree.javaJava
51Construct Binary Tree from Inorder and Postorder Traversal.javaJava
52Construct Binary Tree from Inorder and Preorder Traversal.javaJava
53Container With Most Water.javaJava
54Convert Binary Search Tree to Doubly Linked List.javaJava
55Convert Expression to Polish Notation.javaJava
56Convert Expression to Reverse Polish Notation.javaJava
57Convert Integer A to Integer B.javaJava
58Convert Sorted Array to Binary Search Tree With Minimal Height.javaJava
59Convert Sorted List to Binary Search Tree.javaJava
60Copy List with Random Pointer.javaJava
61Cosine Similarity.javaJava
62Count 1 in Binary.javaJava
63Count and Say.javaJava
64Count of Smaller Number before itself.javaJava
65Count of Smaller Number.javaJava
66Count Primes.javaJava
67Course Schedule II.javaJava
68Course Schedule.javaJava
69Data Stream Median.javaJava
70Delete Digits.javaJava
71Delete Node in the Middle of Singly Linked List.javaJava
72Distinct Subsequences.javaJava
73Edit Distance.javaJava
74Encode and Decode Strings.javaJava
75ExcelSheetColumnNumber .javaJava
76Expression Evaluation.javaJava
77Expression Tree Build.javaJava
78Fast Power.javaJava
79Fibonacci.javaJava
80Find Minimum in Rotated Sorted Array II.javaJava
81Find Minimum in Rotated Sorted Array.javaJava
82Find Peak Element II.javaJava
83Find Peak Element.javaJava
84Find the Connected Component in the Undirected Graph.javaJava
85Find the Weak Connected Component in the Directed Graph.javaJava
86First Bad Version.javaJava
87First Missing Positive.javaJava
88Flatten 2D Vector.javaJava
89Flatten Binary Tree to Linked List.javaJava
90Flattern 2D Vector.javaJava
91Flip Game II.javaJava
92Flip Game.javaJava
93Fraction to Recurring Decimal.javaJava
94Game of Life.javaJava
95Gas Station.javaJava
96Generate Parentheses.javaJava
97Graph Valid Tree.javaJava
98Gray Code.javaJava
99Group Anagrams.javaJava
100Group Shifted Strings.javaJava
101H-Index II.javaJava
102H-Index.javaJava
103Happy Number.javaJava
104Hash Function.javaJava
105HashHeap.javaJava
106HashWithArray.javaJava
107HashWithCustomizedClass(LinkedList).javaJava
108Heapify.javaJava
109House Robber II.javaJava
110House Robber III.javaJava
111House Robber.javaJava
112Identical Binary Tree.javaJava
113Implement Queue by Two Stacks.javaJava
114Implement Stack by Two Queues.javaJava
115Implement Stack.javaJava
116Implement strStr().javaJava
117Implement Trie (Prefix Tree).javaJava
118Implement Trie.javaJava
119IndexMatch.javaJava
120Inorder Successor in Binary Search Tree.javaJava
121Insert Interval.javaJava
122Insert Node in a Binary Search Tree .javaJava
123Insertion Sort List.javaJava
124Integer to English Words.javaJava
125Interleaving Positive and Negative Numbers.javaJava
126Interleaving String.javaJava
127Intersection of Two Linked Lists.javaJava
128Interval Minimum Number.javaJava
129Interval Sum II.javaJava
130Interval Sum.javaJava
131Invert Binary Tree.javaJava
132Isomorphic Strings.javaJava
133Jump Game II.javaJava
134Jump Game.javaJava
135Kth Largest Element.javaJava
136Kth Smallest Element in a BST.javaJava
137Kth Smallest Number in Sorted Matrix.javaJava
138Kth Smallest Sum In Two Sorted Arrays.javaJava
139Largest Number.javaJava
140Largest Rectangle in Histogram.javaJava
141Last Position of Target.javaJava
142Length of Last Word.javaJava
143Letter Combinations of a Phone Number.javaJava
144Linked List Cycle II.javaJava
145Linked List Cycle.javaJava
146Longest Common Prefix.javaJava
147Longest Common Subsequence.javaJava
148Longest Common Substring.javaJava
149Longest Consecutive Sequence.javaJava
150Longest Increasing Continuous subsequence II.javaJava
151Longest Increasing Continuous subsequence.javaJava
152Longest Increasing Subsequence.javaJava
153Longest Palindromic Substring.javaJava
154Longest Substring with At Most K Distinct Characters.javaJava
155Longest Substring Without Repeating Characters.javaJava
156Longest Words.javaJava
157Lowest Common Ancestor II.javaJava
158Lowest Common Ancestor of a Binary Search Tree.javaJava
159Lowest Common Ancestor.javaJava
160LRU Cache.javaJava
161Majority Number II.javaJava
162Majority Number III.javaJava
163Majority Number.javaJava
164Matrix Zigzag Traversal.javaJava
165Max Tree.javaJava
166Maximal Square.javaJava
167Maximum Depth of Binary Tree.javaJava
168Maximum Product Subarray.javaJava
169Maximum Subarray III.javaJava
170MaximumSubarray.javaJava
171MaximumSubarrayII.javaJava
172Median of two Sorted Arrays.javaJava
173Median.javaJava
174Meeting Rooms II.javaJava
175Meeting Rooms.javaJava
176Merge Intervals.javaJava
177Merge k Sorted Arrays.javaJava
178Merge k Sorted Lists.javaJava
179Merge Sorted Array II.javaJava
180Merge Sorted Array.javaJava
181Merge Two Sorted List.javaJava
182Merge Two Sorted Lists.javaJava
183Middle of Linked List.javaJava
184Min Stack.javaJava
185Minimum Height Trees.javaJava
186Minimum Path Sum.javaJava
187Minimum Size Subarray Sum.javaJava
188Minimum Subarray.javaJava
189Minimum Window Substring.javaJava
190MinimumDepthOfBinaryTree.javaJava
191Missing Ranges.javaJava
192Multiply Strings.javaJava
193Next Permutation.javaJava
194Nim Game.javaJava
195NQueens.javaJava
196NQueensII.javaJava
197Nth to Last Node in List.javaJava
198Number of Airplane in the sky.javaJava
199Number of Islands II.javaJava
200Number of Islands.javaJava
201Number Triangles.javaJava
202O(1) Check Power of 2.javaJava
203One Edit Distance.javaJava
204Paint Fence.javaJava
205Palindrome Linked List.javaJava
206Palindrome Partitioning II.javaJava
207Palindrome Partitioning.javaJava
208Palindrome Permutation II.javaJava
209Palindrome Permutation.javaJava
210Partition Array by Odd and Even.javaJava
211Partition Array.javaJava
212Partition List.javaJava
213Pascal's Triangle II.javaJava
214Peeking Iterator.javaJava
215Perfect Squares.javaJava
216Permutation Index.javaJava
217Permutation Sequence.javaJava
218Permutations II.javaJava
219Permutations.javaJava
220Plus One.javaJava
221Populating Next Right Pointers in Each Node II.javaJava
222Populating Next Right Pointers in Each Node.javaJava
223Pow(x,n).javaJava
224Power of Three.javaJava
225Product of Array Exclude Itself.javaJava
226QuickSort.javaJava
227Recover Rotated Sorted Array.javaJava
228Rehashing.javaJava
229Remove Duplicates from Sorted Array.javaJava
230Remove Duplicates from Sorted List II.javaJava
231Remove Duplicates from Sorted List.javaJava
232Remove Duplicates from Unsorted List.javaJava
233Remove Linked List Elements.javaJava
234Remove Node in Binary Search Tree.javaJava
235Remove Nth Node From End of List.javaJava
236Reorder List.javaJava
237Restore IP Addresses.javaJava
238Reverse Integer.javaJava
239Reverse Linked List II .javaJava
240Reverse Linked List.javaJava
241Reverse Words in a String II.javaJava
242Reverse Words in a String.javaJava
243reverseInteger.javaJava
244Roman to Integer.javaJava
245Rotate Image.javaJava
246Rotate List.javaJava
247Rotate String.javaJava
248Search a 2D Matrix II.javaJava
249Search a 2D Matrix.javaJava
250Search for a Range.javaJava
251Search Insert Position.javaJava
252Search Range in Binary Search Tree .javaJava
253Search Rotated in Sorted Array II.javaJava
254Search Rotated in Sorted Array.javaJava
255Segment Tree Build II.javaJava
256Segment Tree Build.javaJava
257Segment Tree Modify.javaJava
258Segment Tree Query II.javaJava
259Segment Tree Query.javaJava
260Serilization and Deserialization Of Binary Tree.javaJava
261Single Number II.javaJava
262Single Number III.javaJava
263Single Number.javaJava
264Singleton.javaJava
265Sliding Window Maximum.javaJava
266Sliding Window Median.javaJava
267Sort Color.javaJava
268Sort Colors II.javaJava
269Sort Letters by Case.javaJava
270Sort List.javaJava
271Space Replacement.javaJava
272Sqrt(x).javaJava
273Stone Game.javaJava
274String to Integer(atoi).javaJava
275Strobogrammatic Number II.javaJava
276Strobogrammatic Number.javaJava
277StrStr.javaJava
278Subarray Sum Closest.javaJava
279Subarray Sum.javaJava
280Subset.javaJava
281Subsets II.javaJava
282Subtree.javaJava
283Summary Ranges.javaJava
284Surrounded Regions.javaJava
285Swap Nodes in Pairs.javaJava
286Symmetric Binary Tree.javaJava
287The Smallest Difference.javaJava
288Top K Frequent Words.javaJava
289Topological Sorting.javaJava
290Total Occurrence of Target.javaJava
291Trailing Zeros.javaJava
292Trapping Rain Water II.javaJava
293Trapping Rain Water.javaJava
294Triangle Count.javaJava
295Tweaked Identical Binary Tree.javaJava
296Two Lists Sum.javaJava
297Two Strings Are Anagrams.javaJava
298Ugly Number II.javaJava
299Ugly Number.javaJava
300Unique Binary Search Tree II.javaJava
301Unique Binary Search Tree.javaJava
302Unique Characters.javaJava
303Unique Path.javaJava
304Unique Paths II.javaJava
305Unique Word Abbreviation.javaJava
306Update Bits.javaJava
307Valid Anagram.javaJava
308Valid Palindrome.javaJava
309Valid Parentheses.javaJava
310Valid Sudoku.javaJava
311Validate Binary Search Tree.javaJava
312Wiggle Sort.javaJava
313Wood Cut.javaJava
314Word Break II.javaJava
315Word Break.javaJava
316Word Ladder II.javaJava
317Word Ladder.javaJava
318Word Pattern.javaJava
319Word Search II.javaJava
320Word Search.javaJava
321Zigzag Iterator.javaJava