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...
分类:
其他好文 时间:
2014-07-18 20:39:06
阅读次数:
556
Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa...
分类:
其他好文 时间:
2014-07-18 20:06:13
阅读次数:
255
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t...
分类:
其他好文 时间:
2014-07-18 20:00:41
阅读次数:
205
Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc...
分类:
其他好文 时间:
2014-07-18 15:07:26
阅读次数:
223
感觉动态规划很模糊,怎么办呢???
狂刷题吧!!!!!!!!!!!!!!!!!!!!!!!!!
1.POJ 2479 Maximum sum
首刷水题!!!!
双向统计最大和。
AC代码如下:
#include
#include
#include
#define inf -1000000000
using namespace std;
int main()
{
int ...
分类:
其他好文 时间:
2014-07-18 12:37:39
阅读次数:
228
Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No...
分类:
其他好文 时间:
2014-07-18 00:32:24
阅读次数:
271
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le...
分类:
其他好文 时间:
2014-07-17 23:27:12
阅读次数:
216
Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret...
分类:
其他好文 时间:
2014-07-17 22:24:40
阅读次数:
216
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l...
分类:
其他好文 时间:
2014-07-17 18:09:32
阅读次数:
258
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ...
分类:
其他好文 时间:
2014-07-17 17:32:50
阅读次数:
246