原创 Leetcode: Construct Binary Tree from Inorder and Postorder Traversal

Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do n

原创 Leetcode: Gas Station

There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with

原创 Leetcode: Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last wo

原创 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 o

原创 Leetcode: Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled,

原创 Leetcode: 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: 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 le

原创 Leetcode: Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and 

原创 Leetcode: Convert Sorted List to Binary Search Tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Similar m

原创 Leetcode: ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to dis

原创 Leetcode: 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: Insertion Sort List

Sort a linked list using insertion sort. /** * Definition for singly-linked list. * public class ListNode { * in

原创 Leetcode: Restore IP Addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations. For exampl

原创 Leetcode: Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is

原创 Leetcode: Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do no