Command Frequency Counter

Problem Overview

  • Count occurrences of cmd1, cmd2, and cmd3 in a command array, resolving any ![index] to the command at that 1-based position.
  • Input: String[] commands; Output: int[3] = [freq(cmd1), freq(cmd2), freq(cmd3)]; only three valid commands.
  • Domain: command log parsing where entries may reference earlier commands.
  • This coding interview problem is an Uber interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: