
trie
文章平均质量分 78
小榕流光
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[leetcode] 208. Implement Trie (Prefix Tree) 解题报告
题目链接: https://leetcode.com/problems/implement-trie-prefix-tree/Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase l原创 2016-03-28 10:38:49 · 724 阅读 · 0 评论 -
[leetcode] 211. Add and Search Word - Data structure design 解题报告
题目链接: https://leetcode.com/problems/add-and-search-word-data-structure-design/Design a data structure that supports the following two operations:void addWord(word)bool search(word)search原创 2016-03-28 10:02:18 · 839 阅读 · 0 评论 -
[leetcode] 212. Word Search II 解题报告
题目链接: https://leetcode.com/problems/word-search-ii/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 sequent原创 2016-03-29 08:53:39 · 3659 阅读 · 1 评论 -
数组中两个元素异或求最大值
给一个整数数组,求数组中两个元素异或的最大值.思路:naive的做法是两两异或求最大值,时间复杂度为O(n*n),但是还有一种O(n)的解法,利用字典树Trie来实现.其思路是利用数组中的每个元素二进制表示形式建一棵树,我看到网上大多数解法都开了太大的数组空间,不知道为什么,但是我觉得没有必要.只要用现有的数组元素二进制值建一棵深度为33的树即可,从根到叶子结点的路径就代表了一个元原创 2016-09-28 22:56:57 · 7335 阅读 · 1 评论 -
[leetcode] 421. Maximum XOR of Two Numbers in an Array 解题报告
题目链接: https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231.Find the maximum result of ai XOR原创 2016-12-01 10:49:34 · 1256 阅读 · 0 评论