All practice tasks

Coding (Algo)

Visible Tag Counts

Hash map · Easy

A tag picker receives duplicate events and must display the frequency of each tag in first-seen order.

Count case-sensitive tags without changing first-appearance ordering.

Input

Call

  • Implement solve(input) and return its result. Do not print from solve.

Input object

{ tags: string[] }

Input rules

  • Empty tag strings are valid.

What each field means

  • tags — tag strings in display order. Case matters, and an empty string is a valid tag.

Output

Return value and rules

  • Return one {tag, count} object for each distinct tag.
  • Count all occurrences, but order the objects by each tag’s first appearance.
  • Do not alphabetically sort the result. Empty input returns [].

Constraints

  • 0 <= tags.length <= 100000; each tag has at most 40 ASCII characters
  • Do not sort tags or mutate input.

Examples

Example 1

{
  "tags": [
    "b",
    "a",
    "b"
  ]
}

Returns

[
  {
    "tag": "b",
    "count": 2
  },
  {
    "tag": "a",
    "count": 1
  }
]

Example 2

{
  "tags": []
}

Returns

[]

Required complexity

O(n) time and O(k) space

What this task practices

Visible Tag Counts is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as easy difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.