All practice tasks

Coding (Algo)

Distinct Activity Window

Sliding window · Medium

An activity panel highlights the longest uninterrupted run without repeating an event kind.

Return the length of the longest contiguous subarray containing distinct kinds.

Input

Call

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

Input object

{ kinds: string[] }

Input rules

  • Strings are case-sensitive event identities.

What each field means

  • kinds — event-kind strings in chronological order. Equal strings represent the same kind.

Output

Return value and rules

  • Return the length of the longest consecutive section with no repeated kind.
  • You may not skip events inside the section.
  • Return 0 for an empty event list.

Constraints

  • 0 <= kinds.length <= 100000; kind length <= 40 ASCII characters
  • A subsequence that skips events is not a valid window.

Examples

Example 1

{
  "kinds": [
    "a",
    "b",
    "a",
    "c"
  ]
}

Returns

3

Example 2

{
  "kinds": []
}

Returns

0

Required complexity

O(n) time and O(k) space

What this task practices

Distinct Activity Window 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 medium 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.