Those my solutions for leetcode.
Search the solution in
Solution.java
by the corresponding method name.
| id | return value | method name | Question | hint | 
|---|---|---|---|---|
| 39 | boolean | searchMatrix(int[][] matrix, int target) | Search a 2D Matrix | Young's Matrix. Searching is started from right-top element | 
| 38 | boolean | wordBreak2(String s, Set wordDict) | Word break | Dp solution | 
| 38 | boolean | wordBreak(String s, Set wordDict) | Word break | Recurse solution with IsBrokenable help | 
- | boolean | IsBrokenable(String s, Set wordDict) | called by 38-word break 37 | ListNode |detectCycleII(ListNode head)|Linked List Cycle II |locate the intersection point using math trick 37 | ListNode |detectCycleII2(ListNode head)|Linked List Cycle II| locate the intersection point by cutting off the circle 36 | ListNode |getIntersectionNode(ListNode headA, ListNode headB)|Intersection of Two Linked Lists | Quick-slow pointers. Other's pretty solution 36 | ListNode |getIntersectionNode1(ListNode headA, ListNode headB)|Intersection of Two Linked Lists | Quick-slow pointers. My verbose solution-_-! 35 | ListNode | addTwoNumbers(ListNode l1, ListNode l2) | Add Two Numbers 34 | void | deleteNode(ListNode node) | Delete Node in a Linked List 33 | ListNode | insertionSortList(ListNode head) | Insertion Sort List 32 | boolean | canJump(int[] nums) 32 | boolean | canJump2(int[] nums) 31 | int | climbStairs(int n) 30 | boolean | containsDuplicate(int[] nums) 29 | boolean | containsNearbyDuplicate(int[] nums, int k) 28 | RandomListNode | copyRandomList(RandomListNode head) 27 | int | findMin(int[] nums) 26 | int | findPeakElement(int[] nums) 26 | int | findPeakElement2(int[] nums) 26 | int | findPeakElement3(int[] nums) 25 | List<List> | generate(int numRows) 24 | List | getRow(int rowIndex)
 - | int | helper(int[][] grid, int i, int j)
 - | void | helper(int[][] matrix, int i, int j, int p, int q, List results)
 - | static void | main(String[] args) 23 | List | majorityElement(int[] nums) 23 | int | majorityElement2(int[] nums) 22 | int | maxArea(int[] height) 22 | int | maxArea2(int[] height) 21 | int | maxProduct(int[] nums) 20 | int | maxSubArray(int[] nums) 19 | void | merge(int[] nums1, int m, int[] nums2, int n) 19 | void | merge2(int[] nums1, int m, int[] nums2, int n) 18 | int | minimumTotal(List<List> triangle) 18 | int | minimumTotal2(Integer[][] triangle) 17 | int | minPathSum(int[][] grid) 17 | int | minPathSum1(int[][] grid) 17 | int | minPathSum2(int[][] grid) 16 | int | nextMonotonyInterval(int[] nums, int start) 15 | int | numTrees(int n) | Unique Binary Search Trees | Catalan number, dp 14 | int | partition(int[] nums, int start, int color) 13 | static int[] | plusOne(int[] digits) 13 | static int[] | plusOne2(int[] digits)
 - | static void | printArray(int[] array) 12 | int | removeDuplicates(int[] nums) 11 | static int | removeElement(int[] nums, int val) 11 | static int[] | removeElement2(int[] nums, int val) 10 | void | reverse(int[] nums, int i, int j) 9 | ListNode | reverse(ListNode head) 8 | void | rotate(int[] nums, int k) 7 | void | sortColors(int[] nums) 6 | List | spiralOrder(int[][] matrix)
 - | void | swap(int[] nums, int i, int j) 5 | List<List> | threeSum(int[] nums) 5 | List<List> | threeSum2(int[] nums) 4 | int | threeSumClosest(int[] nums, int target) 4 | int | threeSumClosest2(int[] nums, int target) 4 | int | threeSumClosest3(int[] nums, int target) 3 | int[] | twoSum(int[] nums, int target) 3 | int[] | twoSum2(int[] nums, int target) 2 | int | uniquePaths(int m, int n) 1 | int | uniquePathsWithObstacles(int[][] obstacleGrid)