题目:有很多不同名称的树,统计每种树出现的概率。
分析:字符串,字典树(trie)。直接利用字典树计数,然后排序输出即可。
说明:POJ2418没有测试组数,TLE几次才发现╮(╯▽╰)╭。
#include
#include
#include
#include
#include
using namespace std;
char words[32];
/* Trie de...
分类:
其他好文 时间:
2014-08-28 18:13:35
阅读次数:
491
【题意】
给定一个字符串,把里面的单词逆序输出来。
例如:给定 s = "the sky is blue",返回 "blue is sky the"。
注意:接收的字符串开头和结尾可能有空格,但是返回时开头和结尾不能有空格;返回时每两个单词之间只能有一个空格。
【Java代码】
public class Solution {
public String reverseWords(...
分类:
其他好文 时间:
2014-08-28 18:10:15
阅读次数:
199
原题戳我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 ha...
分类:
其他好文 时间:
2014-08-28 13:04:59
阅读次数:
162
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-08-26 16:45:16
阅读次数:
250
斜着数 1 import java.util.Scanner; 2 3 public class P1313 4 { 5 public static void main(String args[]) 6 { 7 try (Scanner cin = new Scan...
分类:
其他好文 时间:
2014-08-26 09:42:05
阅读次数:
220
原题戳我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 ha...
分类:
其他好文 时间:
2014-08-26 00:14:25
阅读次数:
334
题目:
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
思路:
方法1:首先把句子看做由词组成的,例如“A B C”,因此可以将句子的所有字符前后交换,得到“C...
分类:
其他好文 时间:
2014-08-25 22:53:04
阅读次数:
194
Bag-of-words简单介绍最初的Bag-of-words ,也叫做“词袋”,在信息检索中,Bag-of-words model假定对于一个文本,忽略其词序和语法,句法,将其只看做是一个词集合,或者说是词的一个组合,文本中每一个词的出现都是独立的,不依赖于其它词是否出现。应用于文本的BoW简单实...
分类:
其他好文 时间:
2014-08-25 14:51:14
阅读次数:
238
Key Words:文件迭代器,标准输入,GUI工具包,数据库操作SQLlite, 文件迭代器>>> f= open("some.txt","r+")>>> while True:... line = f.readline()... if not line : break... else :.......
分类:
编程语言 时间:
2014-08-24 23:37:53
阅读次数:
344
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-08-24 23:32:23
阅读次数:
254