题目: Given an input string, reverse the string word
by word. For example, Given s = "the sky is blue", return "blue is sky
the".解题思路: 1、先对字符串进行一次总...
分类:
其他好文 时间:
2014-05-16 05:44:30
阅读次数:
263
uva 10391 Compound Words (字符串-hash)
题目大意:
有一堆按照字典序排好的字符串,问你有多少字符串是由其它两个字符串组成。
解题思路:
如果用两个字符串拼接看拼接好的字符串是否在字典中,一定会超时。
我们可以逆向,由于字符串的长度不是很长,所以把一个字符串拆为两个字符串看这两个字符串是否都在字典中即可
解题代码一:
判断字符串是否在字典中,可以用STL set,也是轻松AC
解题代码二:
判断字符串是否在字典中,可以用hash,于是手写ha...
分类:
其他好文 时间:
2014-05-16 02:48:12
阅读次数:
377
题目:Given an input string, reverse the string word
by word.For example,Given s = "the sky is blue",return "blue is sky
the".Clarification:What constitu...
分类:
其他好文 时间:
2014-05-13 22:45:04
阅读次数:
317
You are given a string, S, and a list of words,
L, that are all of the same length. Find all starting indices of substring(s) in
S that is a concatena...
分类:
其他好文 时间:
2014-05-12 22:27:04
阅读次数:
265
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=151
For each list of words, output a line with each word reversed without changing the order of the words.
This problem contains multi...
分类:
其他好文 时间:
2014-05-11 22:20:43
阅读次数:
443
Given an array of words and a length L, format
the text such that each line has exactly L characters and is fully (left and
right) justified.You shoul...
分类:
其他好文 时间:
2014-05-11 15:15:29
阅读次数:
287
Command Network Time Limit: 1000MSMemory Limit:
131072K Total Submissions: 11970Accepted: 3482 Description After a long lasting
war on words, a war on...
分类:
Web程序 时间:
2014-05-10 05:27:44
阅读次数:
475
Neal is very curious about combinatorial problems, and now here comes a problem about words. Knowing that Ray has a photographic memory and this may not trouble him, Neal gives it to Jiejie.
Since Ji...
分类:
其他好文 时间:
2014-05-10 03:48:22
阅读次数:
352
Given two words word1 and word2, find the
minimum number of steps required to convert word1 to word2. (each operation is
counted as 1 step.)You have t...
分类:
其他好文 时间:
2014-05-09 19:09:35
阅读次数:
318
我们常常用String的split()方法去分割字符串,有两个地方值得注意:1.
当分隔符是句号时("."),需要转义:由于String.split是基于正则表达式来分割字符串,而句号在正则表达式里表示任意字符。//Wrong://String[]
words = tmp.split(".");//...
分类:
编程语言 时间:
2014-05-08 21:47:41
阅读次数:
444