【题目】
There are N children standing in a line. Each child is assigned a rating value.
You are giving candies to these children subjected to the following requirements:
Each child must have at least one candy.
Children with a higher rating get more candie...
分类:
其他好文 时间:
2014-06-26 13:37:26
阅读次数:
265
【题目】
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 unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an ...
分类:
其他好文 时间:
2014-06-26 13:27:05
阅读次数:
231
【题目】
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "aab",
Return
[
["aa","b"],
["a","a","b"]
]
【题意】
给定一个字符串s, 要求对s进行...
分类:
其他好文 时间:
2014-06-26 13:21:59
阅读次数:
182
【题目】
Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
【题意】
给定一个整数数组,其中除了一个数以外,其他数都是成对出现的,...
分类:
其他好文 时间:
2014-06-26 10:13:27
阅读次数:
254
【题目】
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.
For example, given s = "aab",
Return 1 since the palindrome partitioning ["aa","b"] could b...
分类:
其他好文 时间:
2014-06-26 07:48:00
阅读次数:
259
【题目】
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
OJ's undirected graph serialization:
Nodes are labeled uniquely.
We use # as a separator for each node, and , as a separator for node label and each ne...
分类:
其他好文 时间:
2014-06-26 06:48:16
阅读次数:
285
收集一些常见的小的递归算法,通过训练可以通晓递归的思想。...
分类:
其他好文 时间:
2014-06-25 08:37:06
阅读次数:
200
【题目】
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.
A region is captured by flipping all 'O's into 'X's in that surrounded region.
For example,
X X X X
X O O X
X X O X
X O X X
After running your function, the board shou...
分类:
其他好文 时间:
2014-06-25 08:02:30
阅读次数:
205
【题目】
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
For example,
Given [100, 4, 200, 1, 3, 2],
The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.
Your algorithm should run...
分类:
其他好文 时间:
2014-06-25 07:55:42
阅读次数:
244
【题目】
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find the total sum of all root-to-leaf numbers.
For example,
1
...
分类:
其他好文 时间:
2014-06-25 07:32:27
阅读次数:
209