-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathques-12-trie.java
More file actions
28 lines (24 loc) · 797 Bytes
/
Copy pathques-12-trie.java
File metadata and controls
28 lines (24 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
* QUESTION: Trie — a prefix tree supporting insert(word), search(word) for
* an exact match, and startsWith(prefix) for a prefix match. Used by
* pro-3-rbac-engine to power fast order-ID lookups.
*
* Input: insert("ORD100"); insert("ORD101")
* Output: search("ORD100") -> true, startsWith("ORD1") -> true
*/
class Trie {
void insert(String word) {
throw new UnsupportedOperationException("TODO");
}
boolean search(String word) {
throw new UnsupportedOperationException("TODO");
}
boolean startsWith(String prefix) {
throw new UnsupportedOperationException("TODO");
}
}
// --- TEST ---
// Trie t = new Trie();
// t.insert("ORD100"); t.insert("ORD101");
// System.out.println(t.search("ORD100")); // true
// System.out.println(t.startsWith("ORD1")); // true