(String word)
| 45 | } |
| 46 | |
| 47 | public static int search(String word) { |
| 48 | int cur = 1; |
| 49 | for (int i = 0, path; i < word.length(); i++) { |
| 50 | path = word.charAt(i) - 'a'; |
| 51 | if (tree[cur][path] == 0) { |
| 52 | return 0; |
| 53 | } |
| 54 | cur = tree[cur][path]; |
| 55 | } |
| 56 | return end[cur]; |
| 57 | } |
| 58 | |
| 59 | public static int prefixNumber(String pre) { |
| 60 | int cur = 1; |