DescriptionIgnatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words an...
分类:
其他好文 时间:
2015-01-23 13:10:17
阅读次数:
115
原题地址没有复杂的算法,纯粹的模拟题先试探,计算出一行能放几个单词然后计算出单词之间有几个空格,注意,如果空格总长度无法整除空格数,前面的空格长度通通+1最后放单词、放空格,组成一行,加入结果中对于最后一行要特殊处理代码: 1 vector fullJustify(vector &words, in...
分类:
其他好文 时间:
2015-01-23 12:54:04
阅读次数:
171
原题地址将L中的单词看成一个整体,这道题与Minimun Window String比较类似,都是利用滑动窗口搜索。所以,依次枚举所有S的起始位置i,从i处开始搜索。当然并不需要枚举所有的i,i最多等于L中单词长度-1。比如L中的单词长度为3,那么当枚举过i=0,1,2后,不用再尝试i=3了,因为结...
分类:
其他好文 时间:
2015-01-22 20:09:58
阅读次数:
189
DescriptionIgnatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words an...
分类:
其他好文 时间:
2015-01-21 21:59:44
阅读次数:
192
Most crossword puzzle fans are used to anagrams--groups of words with the same letters in different orders--for example OPTS, SPOT, STOP, POTS and POST. Some words however do not have this attribute, ...
分类:
其他好文 时间:
2015-01-21 18:22:50
阅读次数:
218
题意 输出所有输入单词中可以由另两个单词的组成的词
STL set的应用 枚举每个单词的所有可能拆分情况 看拆开的两个单词是否都存在 都存在的就可以输出了
#include
using namespace std;
string a, b;
set s;
set::iterator i;
int main()
{
int l;
while(cin >> a) s.i...
分类:
其他好文 时间:
2015-01-21 18:13:27
阅读次数:
210
题目:
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.
Return all such possible sentences.
For example, given...
分类:
编程语言 时间:
2015-01-20 22:22:42
阅读次数:
241
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...
分类:
其他好文 时间:
2015-01-20 17:24:35
阅读次数:
125
原题地址动态规划题令s[i..j]表示下标从i到j的子串,它的所有分割情况用words[i]表示假设s[0..i]的所有分割情况words[i]已知。则s[0..i+1]的分割情况words[i+1] = words[k] + s[k+1..i+1],其中(有三个条件要满足)(1) 0 wordB....
分类:
其他好文 时间:
2015-01-20 15:06:21
阅读次数:
157
题目:
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
click to show clarification.
Clarification:
What co...
分类:
编程语言 时间:
2015-01-18 14:30:02
阅读次数:
239