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 ...
分类:
其他好文 时间:
2014-07-22 23:16:14
阅读次数:
408
用shell写了个递归遍历目录的脚本,本脚本实现递归遍历指定目录,打印目录下的文件名(全路径)。#!/bin/sh function scandir() {
local cur_dir parent_dir workdir workdir=$1 cd ${workdir} if [ ${w...
分类:
其他好文 时间:
2014-07-22 23:14:53
阅读次数:
563
Given a string, find the length of the longest
substring without repeating characters. For example, the longest substring
without repeating letters fo...
分类:
其他好文 时间:
2014-07-22 23:11:32
阅读次数:
388
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-22 23:07:13
阅读次数:
379
这道题挺简单的,但是需要细心。最好的方法是先对string做预处理,然后再判断是否是回文。下面是AC代码:
1 /** 2 * Given a string, determine if it is a palindrome, considering only
alphanumeric ch...
分类:
其他好文 时间:
2014-05-01 01:45:34
阅读次数:
375
在程序设计竞赛中,我们时常会遇到序列求最值的问题。在讲今天的问题之前,先小小的说明一下,子序列与子串的问题。
子序列:在原序列中不一定连续; 子串:在原序列中必须连续。 接下来,就开始今天要讲的最长公共子序列LCS(Longest Common
Subsequence).对于LCS这一类的...
分类:
其他好文 时间:
2014-05-01 01:38:24
阅读次数:
287
Problem description:given a string, find the
longest palindrome string in itSolution:1.brute force O(n^3)just enumerate start
and end of the substring...
分类:
其他好文 时间:
2014-04-29 17:22:46
阅读次数:
308
Validate if a given string is numeric.Some
examples:"0"=>true" 0.1 "=>true"abc"=>false"1
a"=>false"2e10"=>trueNote:It is intended for the problem stat...
分类:
其他好文 时间:
2014-04-29 16:45:45
阅读次数:
398
http://acm.hdu.edu.cn/showproblem.php?pid=1595
大致题意:
给一个图,让输出从中删除任意一条边后所得最短路径中最长的。。
思路:
直接枚举每条边想必是不行的。其实有些边是不需要枚举的,因为删除它们并不影响起点到终点的最短路。起作用的边都是未删边前的最短路径上的边,删除它们最短距离肯定增大,只需在这些最短距离中求最大的即可。
记录最短路...
分类:
Web程序 时间:
2014-04-28 10:24:42
阅读次数:
393
关键是通过预处理吧每个区间内的一移动到一起的最少步骤算出来....
1411: Longest Consecutive Ones
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 185 Solved: 40
[Submit][Status][Web
Board]
Description
Given a...
分类:
其他好文 时间:
2014-04-27 21:21:05
阅读次数:
305