- 浏览: 92082 次
- 性别:
- 来自: 南京
最新评论
文章列表
SubsetsApr 18 '126226 / 16269
Given a set of distinct integers, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.
Unique Paths IIMar 29 '124573 / 11497
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is marked as 1 and
Flatten Binary Tree to Linked ListOct 14 '127105 / 21371
Given a binary tree, flatten it to a linked list in-place.
For example,Given
1
/ \
2 5
/ \ \
3 4 6
The flattened tree should look like: 1
\
2
\
3
...
TriangleOct 30 '126503 / 17796
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
For example, given the following triangle
[
[2],
[3,4],
[6,5,7],
[4,
Balanced Binary TreeOct 9 '127722 / 18479
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees ofevery node never differ by more than 1.
看清题目很重要!
这里ba ...
Rotate ImageMar 18 '124182 / 9471
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:Could you do this in-place?
这题我第一次做时候,实现的非常复杂。人肉实现rotate。code很麻
Permutations IIMar 17 '124943 / 12877
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and
Jump GameMar 25 '126923 / 16241
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Determine if you are able to reach the last index.
For example:A =
Wildcard MatchingMar 16 '127489 / 29783
Implement wildcard pattern matching with support for '?' and '*'.
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).
The matching should cover the entire input string (not partial).
The function ...
Multiply StringsMar 12 '124253 / 16074
Given two numbers represented as strings, return multiplication of the numbers as a string.
Note: The numbers can be arbitrarily large and are non-negative.
把num reverse一下,这个技巧挺实用,可以拓展到所有的string运算中。
class Solution {
public:
string multiply ...
Trapping Rain WaterMar 10 '124164 / 10550
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6.
First Missing PositiveMar 8 '125401 / 16835
Given an unsorted integer array, find the first missing positive integer.
For example,Given [1,2,0] return
Combination SumMar 7 '125736 / 16047
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in
Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...
1 is read off as "one 1" or
Longest Valid ParenthesesMar 1 '125700 / 20657
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
For "(()", the longest valid parentheses substring is