原创 LeetCode - Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, given 1->1->2,
原创 LeetCode - Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm shoul
原创 LeetCode - Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the
原创 LeetCode - Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321; x = -123, return -321 http://oj.leetcode.com/problems/reve
原创 LeetCode - Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode
原创 LeetCode - Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if th
原创 LeetCode - Linked List Cycle
Given a linked list, determine if it has a cycle in it. http://oj.leetcode.com/problems/linked-list-cycle/ Solution: V
原创 LeetCode - Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integ
原创 LeetCode - Permutations
Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the following permutations:
原创 LeetCode - Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to c
原创 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 sp
原创 LeetCode - Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary
原创 LeetCode - Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tre
原创 LeetCode - Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should retur
原创 LeetCode - Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In ho