Below is a snippet from a trie implementation (the trie is stored in the 1-indexed vector t):
int get(int &u) {
if (!u) {
t.emplace_back();
u = size(t)-1;
}
return u;
}
int insert(string s) {
int u = 1;
for (char c : s) {
u = get(t[u].child[c-'a']);
}
return u;
}
This code is incorrect; can you figure out why?









