Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package others.trie;
- import others.trie.Trie;
- import others.trie.TrieNode;
- import java.util.ArrayList;
- public class PrefixSearchByRequests {
- public static void main(String[] args) {
- Trie trie = new Trie();
- trie.add("boo",3);
- trie.add("bool",12);
- trie.add("boolshit",1);
- trie.add("boold",2);
- ArrayList<TrieNode> res = trie.findMostPopular("boo");
- res.forEach(
- n -> {
- System.out.print(n.getWord());
- System.out.print(": ");
- System.out.println(n.getRequests());
- });
- }
- }
Add Comment
Please, Sign In to add comment