← Questions

Earliest release that supports a feature

0
OpenAICodingLast asked Mar 2026

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.

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