First Bad Version | Day 1 | [May LeetCoding Challenge] [2020]

Опубликовано: 05 Август 2026
на канале: Algorithms Made Easy
1,080
24

The day 1 problem in May Leetcoding Challenge ( First Bad Version ).
One of Facebook's most commonly asked interview questions according to LeetCode.

Coding Interviews First Bad Version (LeetCode) question and explanation.

This interview question is commonly asked by the following companies: Facebook and Google.

Problem description: You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.

Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad.

You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.

Example:
Given n = 5, and version = 4 is the first bad version.
call isBadVersion(3) returns false
call isBadVersion(5) returns true
call isBadVersion(4) returns true
Then 4 is the first bad version.

If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful.

Code Link: https://github.com/Algorithms-Made-Ea...

#coding #leetcode #softwareengineering #algorithmsMadeEasy