Junior — Senior
Selection of correct software versions until the first problematic one
livecode
Task condition
Given an array of software versions, among which one (or more) may be defective. There exists a function is_bad_version(version)— returning True if the given version contains a bug, and False otherwise. It is required to implement a function that takes a list of versions and returns a new list consisting of all elements before the first found defective version (excluding the defective version itself and all subsequent elements).
Example 1:
Input: versions = ["1.0", "1.1", "1.2"], with is_bad_version("1.1") = True.
Output: ["1.0"]
Example 2:
Input: versions = ["2.0", "2.1", "2.2"], with is_bad_version("2.0") = True.
Output: []