原创 Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element
原创 Merge Intervals
Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], ret
原创 Word Ladder
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to
原创 Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row
原创 Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element
原创 Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5
原创 [LeetCode] - Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left
原创 Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then righ
原创 [LeetCode] - Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of
原创 Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations. For examp
原创 [LeetCode] - Word Break II
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid
原创 Pow(x, n)
Implement pow(x, n). Analysis: public class Solution { public double power(double x, int n) { if(n==0) ret
原创 Word Search
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequen
原创 [LeetCode] - Sqrt(x)
Implement int sqrt(int x). Compute and return the square root of x. 這是一個關於二分法的題目。需要注意的是,乘法有可能會溢出,所以需要使用long定義mid這個變量。
原创 Divide Two Integers
Divide two integers without using multiplication, division and mod operator. Version 1: Not that efficient for large n