Company: Oracle
Difficulty: medium
Binary Autocomplete The programming interface for a legacy motor controller accepts commands as binary strings of variable length. The console has a very primitive autocomplete/autocorrect feature: as a new command is entered one character at a time, it will display the previously entered command that shares the longest common prefix . If multiple commands are tied, it displays the most recent one. If there is no previous command that shares a common prefix, it will display the most recent command. Given a sequence of commands entered into the console, for each command, determine the index of the command last displayed by the autocomplete as it was entered. Return 0 if there is none. Input Format The function autocomplete has the following parameter(s): string command[n] : an array of strings where command[i] denotes the (i+1)th entered command, 0 ≤ i Returns int : an array of integers Constraints 2 ≤ n ≤ 10 5 1 ≤ |command[i]| ≤ 30 where (0 ≤ i Example Sample Case 1: n = 6 command = [\