Guest User

Untitled

a guest
Nov 8th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. package others.trie;
  2.  
  3. import others.trie.Trie;
  4. import others.trie.TrieNode;
  5.  
  6. import java.util.ArrayList;
  7.  
  8. public class PrefixSearchByRequests {
  9. public static void main(String[] args) {
  10. Trie trie = new Trie();
  11. trie.add("boo",3);
  12. trie.add("bool",12);
  13. trie.add("boolshit",1);
  14. trie.add("boold",2);
  15. ArrayList<TrieNode> res = trie.findMostPopular("boo");
  16. res.forEach(
  17. n -> {
  18. System.out.print(n.getWord());
  19. System.out.print(": ");
  20. System.out.println(n.getRequests());
  21. });
  22. }
  23. }
Add Comment
Please, Sign In to add comment