← Questions

Earliest release that supports a feature

0
OpenAICodingLast asked Mar 2026

A coding interview question asked in OpenAI's agentic coding (beta) round, last asked Mar 2026. It tests binary-search, versioning and api probing.

You ship a library whose releases are listed in versions, sorted from oldest to newest. Each entry is a "MAJOR.MINOR.PATCH" string; parts are non-negative integers and may be zero-padded ("4.007.02" is 4.7.2). A feature your application needs was added in some release. You can only learn whether a release has it through a rate-limited black box:

class VersionChecker:
    def is_supported(self, version: str) -> bool: ...

Return the earliest release that supports the feature, or None if none does. Every call to is_supported counts, so use far fewer calls than len(versions).

Part 1

Once a release supports the feature, every later release does too.

Part 2

Support is no longer monotone across the whole list: a later minor or patch release can drop the feature and an even later one can restore it. You may rely on these rules:

  • Majors: once some major contains a supporting release, every later major contains at least one.
  • Minors: inside the first supporting major, once a minor contains a supporting release, every later minor of that major does too.
  • Patches: inside the first supporting minor, support is monotone across patches.
  • If a major (or a major.minor) contains any supporting release, its newest listed release supports the feature.

The answer is still the earliest supporting release in the whole list.

Constraints

  • 0 <= len(versions) <= 200,000; versions are distinct and sorted by numeric value.
  • Compare versions numerically: "10.0.0" is newer than "9.9.9".

Example 1 (Part 1)

versions  = ["0.9.0", "1.0.0", "1.0.1", "1.1.0", "2.0.0"]
supported = {"1.0.1", "1.1.0", "2.0.0"}
answer    = "1.0.1"

Example 2 (Part 2)

versions  = ["5.0.0", "5.1.0", "6.0.0", "6.0.2", "6.1.0", "6.1.3", "7.0.0"]
supported = {"6.0.2", "6.1.3", "7.0.0"}
answer    = "6.0.2"

6.1.0 lacks the feature even though 6.0.2 has it, so probing 6.1.0 and moving right would miss the answer.

Clarifying questions

  • Can I parse and group versions freely (no cost), with only is_supported calls counting?
  • Part 2: does "contains a supporting release" for a major mean any of its patches across all minors?
  • If the first supporting major has only one minor, or the first supporting minor has one patch, is that a single probe?
  • Is an empty versions list None without any call?

What a strong answer covers

  • Parsing each version into an integer tuple, so zero-padded parts compare correctly, without using string comparison.
  • Part 1: a plain binary search for the first supported index, O(log n) calls.
  • Part 2: three nested searches using the stated rules. Group by major; binary search the majors using each major's newest release as its probe (monotone by rule 1 and rule 4); inside the first supporting major, binary search its minors by their newest release; inside the first supporting minor, binary search the patches.
  • Explaining why probing an arbitrary middle release fails in Part 2 (Example 2: 6.1.0 is unsupported though 6.0.2 is), and why the newest release of a group is the right probe.
  • Call count O(log majors + log minors + log patches); tests on both examples, a single release, no supported release, and every release supported.

Follow-ups

  • Cache results so repeated queries for nearby features cost fewer calls.
  • Calls can fail or return wrong answers sometimes: make the search robust.
  • Find the full set of release ranges that support the feature.
  • Several features at once: share probes between searches.

Where it's asked

  • OpenAI · Agentic coding (beta) · Last asked Mar 2026An existing codebase and changes too large to write by hand; you work through them with an AI coding agent · An AI coding agent is expected

What it tests

binary-search · versioning · api probing

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding