All practice tasks

Coding (Algo)

Count Repeated Event Types

Hash map · Easy

A monitoring report needs the number of event types occurring often enough to investigate. Repeated deliveries contribute to a type’s frequency, but the report counts each qualifying type once rather than counting its occurrences.

Return the number of distinct event values whose total frequency is at least k.

Input

Call

  • Implement solve(input) and return the result. The provided adapter handles JSON input and output.

Input shape

{ nums: integer[], k: integer }

Fields

  • nums is an array of signed integers in its original order. Equal values at different indexes are separate entries.
  • k is the positive minimum frequency required for a value to qualify.

Output

Return value

  • Return a count of distinct values, not occurrences. Equality with k qualifies.
  • Return 0 for an empty input or when no frequency reaches k.

Constraints

  • 0 <= nums.length <= 100000; -1000000000 <= nums[i] <= 1000000000.
  • All requested totals and counts fit exactly in a safe JSON integer.
  • 1 <= k <= 100001.

Examples

Example 1

{
  "k": 2,
  "nums": [
    2,
    2,
    2,
    5,
    5,
    8
  ]
}

Returns

2

Example 2

{
  "k": 2,
  "nums": [
    4,
    4,
    4
  ]
}

Returns

1

Required complexity

O(n) expected time and O(u) space for u distinct values

What this task practices

Count Repeated Event Types 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.