本文共 484 字,大约阅读时间需要 1 分钟。
思路:
无class TrieNode { // Initialize your data structure here. TrieNode charecters[]; boolean end; public TrieNode() { charecters=new TrieNode[26]; end=false; }}public class Trie { private TrieNode root; public Trie() { root = new TrieNode(); root.charecters=new TrieNode[26]; } // Inserts a word into the trie. public void insert(String word) { int n=word.length(); TrieNode temp=root; for(int i=0;i
转载地址:http://cduvb.baihongyu.com/