LeetCode 278 First Bad Version

LeetCode 278 First Bad Version Problem

Download Code
# The isBadVersion API is already defined for you.
# @param version, an integer
# @return a bool
# def isBadVersion(version):

class Solution(object):
    def firstBadVersion(self, n):
        :type n: int
        :rtype: int
        left, right= 1, n
        while left < right:
            mid = (right + left) / 2
            if isBadVersion(mid):
                right = mid
                left = mid + 1
        return left
Download First Bad Version.py

List of all First Bad Version problems

Leetcode 278 First Bad Version problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.

Feedback is the most important part of any website.

If you have any query, suggestion or feedback, Please feel free to contact us.