![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Trie
dezhonger
这个作者很懒,什么都没留下…
展开
-
Leetcode211
Trie+递归 class WordDictionary { Trie root; /** * Initialize your data structure here. */ public WordDictionary() { root = new Trie(); } /** * Adds a wo...原创 2020-01-04 23:40:13 · 61 阅读 · 0 评论 -
Leetcode 692
求出现频率最多的k个单词 1、使用优先队列解法 public List<String> topKFrequent(String[] words, int k) { List<String> res = new ArrayList<>(); Map<String, Integer> map = new...原创 2019-12-28 15:02:36 · 161 阅读 · 0 评论 -
Leetcode677
trie: 维护当前节点的值,当前节点对应前缀的值 public class MapSum { /** * Initialize your data structure here. */ Trie trie; public MapSum() { trie = new Trie(); } public void i...原创 2019-12-12 23:54:05 · 69 阅读 · 0 评论 -
Leetcode 421
给定一个数组,求两个数异或后的值最大是多少 sol: 注意到异或一个性质, 如果a^b=c那么 b^c=a 详细的题解看这里,https://kingsfish.github.io/2017/12/15/Leetcode-421-Maximum-XOR-of-Two-Numbers-in-an-Array/ 写的非常好 public int fin...原创 2019-12-01 16:05:06 · 147 阅读 · 0 评论 -
Leetcode648 Replace Words
https://leetcode.com/problems/replace-words/ 就是要找出每个单词的最短前缀,使用Trie来做。 import java.util.List; /** * Created by dezhonger on 2019/7/17 * trie */ public class Leetcode0648 { public String rep...原创 2019-07-17 12:32:11 · 114 阅读 · 0 评论