All practice tasks

Coding (Algo)

Healthy Instance IDs

Filtering · Easy

A control plane receives one health snapshot per instance. Traffic may go only to ready instances below a fixed error threshold.

Return eligible IDs in ascending ASCII order.

Input

Call

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

Input object

{ instances:{id:string,ready:boolean,errors:integer}[], maximumErrors:integer }

Input rules

  • IDs are unique.

What each field means

  • instances — unique IDs with readiness flags and error counts.
  • maximumErrors — largest permitted error count, inclusive.

Output

Return value and rules

  • Return IDs with ready: true and errors <= maximumErrors.
  • Sort IDs in ASCII order. A low error count does not compensate for not being ready.
  • No eligible instances produce [].

Constraints

  • 0 <= instances.length <= 100000; errors and maximumErrors in [0,1000000]
  • IDs are nonempty lowercase ASCII strings of at most 40 characters.

Examples

Example 1

{
  "instances": [
    {
      "id": "b",
      "ready": true,
      "errors": 2
    },
    {
      "id": "a",
      "ready": true,
      "errors": 1
    },
    {
      "id": "c",
      "ready": false,
      "errors": 0
    }
  ],
  "maximumErrors": 1
}

Returns

[
  "a"
]

Example 2

{
  "instances": [],
  "maximumErrors": 0
}

Returns

[]

Required complexity

O(n log n) time and O(n) space

What this task practices

Healthy Instance IDs 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.