ByteDance interview question

implement an input with auto-completion function