完全抄答案class TrieNode { // Initialize your data structure here. // ref http://www.programcreek.com/2014/05/leetcode-implement-trie-prefix-tree-jav...
分类:
其他好文 时间:
2015-05-27 07:26:48
阅读次数:
195
题目链接:
hihocoder 1014
代码:
#include
#include
#include
using namespace std;
struct node{
int ans;
node* next[26];
node()
{
ans=1;
for(int ii=0;ii<26;ii++)
...
分类:
其他好文 时间:
2015-05-25 22:37:07
阅读次数:
258
Problem Description
Zeus 和 Prometheus 做了一个游戏,Prometheus 给 Zeus 一个集合,集合中包含了N个正整数,随后 Prometheus 将向 Zeus 发起M次询问,每次询问中包含一个正整数 S ,之后 Zeus 需要在集合当中找出一个正整数 K ,使得 K 与 S 的异或结果最大。Prometheus 为了让 Zeus 看到人类的伟大,随即同意...
分类:
其他好文 时间:
2015-05-25 16:46:59
阅读次数:
88
后缀自动机扩展到树形结构上。先建出大的Trie,然后我们得到了一棵Trie树,对于树上的每个节点,保存一个后缀自动机从根走它代表的字符串后到达的节点,每次其儿子就从父亲的这个节点开始扩展。 1 /***************************************************....
分类:
其他好文 时间:
2015-05-21 22:15:25
阅读次数:
213
LeetCode Word Search II题目思路结合Trie和DFS即可。
用C写真是虐心。
也不知道有没有内存泄露。
如有,望指正。代码struct TrieNode {
char c;
// sons for "abcdefghijklmnopqrstuvwxyz\0"
struct TrieNode * son[27];
};struct TrieNod...
分类:
其他好文 时间:
2015-05-21 09:06:17
阅读次数:
163
Trie, again.class TrieNode {public: // Initialize your data structure here. TrieNode() : prev(nullptr), c(0), bIsLast(false) { } TrieNo...
分类:
其他好文 时间:
2015-05-20 07:07:16
阅读次数:
119
I'm glad to see that LeetCode has finally realized the importance of Trie.My C++ code can be further optimized..class TrieNode {public: // Initiali...
分类:
其他好文 时间:
2015-05-20 02:04:05
阅读次数:
147
【题目】
Given a 2D board and a list of words from the dictionary, find all words in the board.
Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are...
分类:
其他好文 时间:
2015-05-19 19:10:30
阅读次数:
214
博客详解:http://www.cnblogs.com/huangxincheng/archive/2012/11/25/2788268.htmlhttp://eriol.iteye.com/blog/1166118http://www.360doc.com/content/12/1116/15/9...
分类:
其他好文 时间:
2015-05-19 12:35:47
阅读次数:
176
题意:实现添加单词和查找单词的作用,即实现字典功能。思路:'.' 可以代表一个任何小写字母,可能是".abc"或者"a.bc"或者"abc.",能应对这三种就没有问题了。在每个单词的尾字母上标上tag=1,代表从树根到此节点有一个单词。暂时想不到更快的办法。 1 class WordDictiona...
分类:
其他好文 时间:
2015-05-18 14:27:46
阅读次数:
138