原创 Divide Two Integers

Divide two integers without using multiplication, division and mod operator. The idea is to use bit operations.  The key

原创 Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum o

原创 Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it

原创 Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Give

原创 Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome

原创 Populating Next Right Pointers in Each Node II

Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Wou

原创 Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in t

原创 我的友情鏈接

51CTO博客開發

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

原创 Search in Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1

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

原创 Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move

原创 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 an u

原创 Permutations

Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,

原创 Insertion Sort List

Sort a linked list using insertion sort.把插入排序應用在linkedlist上面,做一點小小的變動,之前查找到需要改變位置的元素的時候從後往前一步一步挪,因爲是singlelinkedlist,則需要