This is a verified interview question from Uber. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Driver Console Autocomplete" covers key patterns like Strings.
"Uber's in-car driver console accepts binary command strings to trigger various system functions. To improve driver experience, Uber wants to implement an autocomplete system. Autocomplete Rules For each new command: Suggest the previous command that has the longest common prefix with the current command. If no previous command shares a prefix, suggest the most recent command. If multiple commands share the same longest prefix, suggest the most recent one. If there are no previous commands, return 0. You must return an array where the iᵗʰ element represents the index (1-based) of the suggested command for drive_commands[i]. Function Signature int[] systemConsole(String[] drive_commands) Example Input: n = 6 drive_commands = ["000", "110", "01", "001", "110", "11"] Output: [0, 1, 1, 1, 2, 5] Explanation "000" → 0 (no previous command) "110" → 1 (no prefix match → suggest most recent "000") "01" → 1 (shares prefix "0" with "000") "001" → 1 (shares prefix "00" with "000") "110" → 2 (shares "11" with second command) "11" → 5 (shares "11" with fifth command — most recent)"
Join thousands of developers practicing for Uber.