原创 Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined a
原创 Best Time to Buy and Sell Stock II
ay you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find th
原创 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 tr
原创 String to Integer (atoi)
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a ch
原创 Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you so
原创 Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the
原创 Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from th
原创 Pow(x, n)
Implement pow(x, n). class Solution { public: double pow(double x, int n) { if(x==0) return 0; if(n
原创 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets
原创 Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected grap
原创 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
原创 Text Justification
Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (lef
原创 Permutations
Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the following permutations:
原创 Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For exa
原创 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Retur