Company: Amgen technology_17oct
Difficulty: medium
Motor Controller Autocomplete An old motor controller is driven from a console that only accepts binary strings as commands. The console has an autocomplete feature that suggests one of the commands you have already typed. The commands are typed one after another. commands[i] is the i -th command typed, and the commands are numbered 1, 2, ..., n in the order they are typed. While you type the i -th command, the console looks at the commands 1, 2, ..., i - 1 that were typed before it and displays exactly one of them: the earlier command that shares the longest common prefix with the command being typed; if several earlier commands share that same longest prefix, the most recently typed one of them; if no earlier command shares any prefix at all with it, the most recently typed command; if there is no earlier command at all -- that is, for the very first command -- nothing is displayed. The common prefix of two commands is the longest string that starts both of them, and its length is 0