What goes in the blank?
# trie as nested dicts: insert one word
node = root
for ch in word:
node = node.setdefault(ch, ____)
node['$'] = True
Answer: {}
setdefault returns the existing child or creates an empty dict for it, so the walk continues one level deeper per character.
Play Problem Solving ▸