原创 LeetCode:Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 先建一個空頭,作爲返回鏈表的首節點
原创 LeetCode:Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1],
原创 LeetCode:Interleaving String
Interleaving String Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given
原创 LeetCode:Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given
原创 LeetCode:Jump Game I && II
Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array.
原创 Java synchronized關鍵字的認識
具體實現的原理不贅述,博客很多,這裏主要總結使用方法。假設有class A和對象的兩個實例a1, a2; synchronized 用法是作爲函數修飾符或者函數內語句塊修飾符,其實兩者是相通的, publ
原创 LeetCode:Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes
原创 LeetCode:Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000,
原创 LeetCode:Insert Interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assu
原创 LeetCode:Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough s
原创 LeetCode: Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example,
原创 LeetCode:Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water
原创 LeetCode:Path Sum I &&II
Path Sum Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the
原创 LeetCode:Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 由於是有序表,直接遞歸生成。 /** *