All practice tasks

Coding (Algo)

Shared Record IDs

Hash set · Easy

A client and API compare record IDs to identify shared records. Duplicate IDs on either side must not duplicate the result.

Return the set intersection in ascending numeric order.

Input

Call

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

Input object

{ client:integer[], server:integer[] }

What each field means

  • client and server — integer record IDs from the two sides; duplicates are allowed.

Output

Return value and rules

  • Return IDs present in both arrays, with each ID appearing once.
  • Sort numerically in ascending order.
  • No shared IDs produce [].

Constraints

  • Each input has at most 100000 elements
  • IDs in [0,1000000000]; do not mutate the arrays.

Examples

Example 1

{
  "client": [
    3,
    1,
    1
  ],
  "server": [
    1,
    3,
    3,
    4
  ]
}

Returns

[
  1,
  3
]

Example 2

{
  "client": [],
  "server": []
}

Returns

[]

Required complexity

O(n + m + k log k) time and O(n + m) space

What this task practices

Shared Record 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.