原创 Recover Binary Search Tree
/*struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(N
原创 Jump Game II
class Solution { public: int jump(int A[], int n) { //table[i] 爲 i jump to n-1 的最少步數,超時 int *table=new int[n];
原创 Word Search
class Solution { public: bool exist(vector<vector<char> > &board, string word) { bool *used= new bool[board.siz
原创 Best Time to Buy and Sell Stock II
class Solution { public: int maxProfit(vector<int> &prices) { int sum = 0; for (int i = 1; i < pric
原创 Longest Palindromic Substring
Manacher算法解釋:http://tarokuriyama.com/projects/palindrome2.php class Solution { public: string longestPalindrome(s
原创 Maximal Rectangle
class Solution { public: int maximalRectangle(vector<vector<char> > &matrix) { //轉換矩陣,變成Largest Rectangle
原创 Trapping Rain Water
//fun... class Solution { public: int trap(int A[], int n) { if(n<3) return 0; vector<int> left_max(n,0),right
原创 Morris遍歷
解釋:點擊打開鏈接 #include<string> #include<vector> #include<iostream> #include<queue> #include<unordered_set> #include<algori
原创 Best Time to Buy and Sell Stock III
class Solution { public: int maxProfit(vector<int> &prices) { int n=prices.size(); if(n==0) return 0; //從
原创 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
原创 Jump Game
class Solution { public: bool canJump(int A[], int n) { if(n==1) return true; int pre=0,cur=A[0],n
原创 Candy
There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these child
原创 Word Ladder
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to e
原创 Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 an
原创 Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be