Company: Oracle
Difficulty: medium
Binary Autocomplete A dated firmware console for a robotic arm only accepts commands written as binary strings of varying length, and it offers a bare-bones suggestion feature: while a new command is being typed character by character, the console shows whichever earlier command shares the longest matching prefix with what has been typed so far. When several earlier commands tie for the longest prefix, the one entered most recently is shown. When no earlier command shares any prefix at all, the console simply shows the most recently entered command. Given the order in which commands were typed into the console, work out, for every command, the index of whichever command the suggestion feature was showing once that command had been fully entered. Use 0 when nothing was shown. 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 Constrai