All practice tasks

Coding (Algo)

Required Marker Windows

Sliding window · Medium

A log scanner looks for short excerpts containing exactly a required multiset of markers. Marker order is irrelevant, but repeated markers count separately.

Return every start index of a fixed-length excerpt that contains exactly the required marker counts.

Input

Call

  • Implement solve({text, required}).

Markers

  • text is the log marker sequence.
  • required defines both the excerpt length and the count of every letter. For AAB, two As and one B are required.

Output

Matches

  • Return each start index whose next required.length characters have exactly the required letter counts.
  • Order does not matter inside a match. Include overlapping matches.
  • Return [] for an empty requirement or when no full window matches.

Constraints

  • 0 <= text.length <= 100000; 0 <= required.length <= 10000.
  • Characters are A..Z. Inputs are valid; no Unicode normalization is needed.

Examples

Example 1

{
  "required": "ABC",
  "text": "CBAEBABACD"
}

Returns

[
  0,
  6
]

Example 2

{
  "required": "AAB",
  "text": "AAAB"
}

Returns

[
  1
]

Required complexity

O(n + m) time and O(26) auxiliary space excluding output

What this task practices

Required Marker Windows 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.