【题目】
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 i...
分类:
其他好文 时间:
2015-01-04 23:07:30
阅读次数:
233
Valid ParenthesesGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must clos...
分类:
其他好文 时间:
2015-01-04 22:44:54
阅读次数:
263
First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Yo...
分类:
其他好文 时间:
2015-01-03 23:39:20
阅读次数:
166
Best Time to Buy and Sell Stock IIQuestion SolutionSay you have an array for which the ith element is the price of a given stock on day i.Design an al...
分类:
其他好文 时间:
2015-01-03 19:45:09
阅读次数:
140
Best Time to Buy and Sell Stock IIIQuestion SolutionSay you have an array for which the ith element is the price of a given stock on day i.Design an a...
分类:
其他好文 时间:
2015-01-03 19:43:30
阅读次数:
171
Best Time to Buy and Sell StockSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to compl...
分类:
其他好文 时间:
2015-01-03 19:43:30
阅读次数:
205
题目链接:http://codeforces.com/problemset/problem/500/B题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn。紧接着是一个 n * n 的矩阵A,当且仅当 Aij = 1 时,pi 与 pj 可以交换数值。现在问如何交换数值...
分类:
其他好文 时间:
2015-01-03 17:18:48
阅读次数:
162
Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may assu...
分类:
其他好文 时间:
2015-01-03 17:18:44
阅读次数:
136
【问题描述】
A城市有一个巨大的圆形广场,为了绿化环境和净化空气,市政府决定沿圆形广场外圈种一圈树。园林部门得到指令后,初步规划出n个种树的位置,顺时针编号1到n。并且每个位置都有一个美观度Ai,如果在这里种树就可以得到这Ai的美观度。但由于A城市土壤肥力欠佳,两棵树决不能种在相邻的位置(i号位置和i+1号位置叫相邻位置。值得注意的是1号和n号也算相邻位置!)。
最终市政府给园林部门提供了m棵...
分类:
其他好文 时间:
2015-01-03 16:00:49
阅读次数:
163
Longest Common SubsequenceGiven two strings, find the longest comment subsequence (LCS).Your code should return the length of LCS.样例For "ABCD" and "ED...
分类:
其他好文 时间:
2015-01-03 15:55:06
阅读次数:
177