278 First Bad Version | Zero to FAANG | Searching in Arrays | Leetcode

preview_player
Показать описание
278 First Bad Version | Zero to FAANG | Searching in Arrays | Leetcode

Problem link :

Course link:

Complete Java + DSA + Interview Preparation + CP Course

Hi, thanks for watching our video about Arrays in Java
In this video we’ll walk you through:
- Brute Force
- Linear Search
- Binary Search

TIMESTAMPS
Intro
Explanation begins
IDE solution

ABOUT OUR CHANNEL
Our channel is all about Programming. We cover lots of cool stuff such as solution to problems, concept explanation and tricks to master CP
Check out our channel here:
Don’t forget to subscribe!

CHECK OUT OUR OTHER Playlists

GeeksforGeeks playlist:

Complete C++ Course playlist:

CodeChef Playlist:

HackerRank playlist:

LeetCode problems

FIND US AT

GET IN TOUCH

278. First Bad Version
Easy

2932

987

Add to List

Share
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 returns whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.



Example 1:

Input: n = 5, bad = 4
Output: 4
Explanation:
call isBadVersion(3) - false
call isBadVersion(5) - true
call isBadVersion(4) - true
Then 4 is the first bad version.
Example 2:

Input: n = 1, bad = 1
Output: 1


Constraints:

1 = bad = n = 231 - 1
Accepted
655,681
Submissions
1,669,128

#codechef #coding #python #hackerrank #programming #java #computerscience #coder #code #competitiveprogramming #machinelearning #pythonprogramming #algorithms #cpp #javascript #hackerearth #webdeveloper #geeksforgeeks #codinglife #leetcode #c #codeforces #engineering #codingmemes #programmer #hacker #programmingmemes #topcoder #webdevelopment #bhfyp #DSAwithKunal
Рекомендации по теме
Комментарии
Автор

ham yaha ans ki initial value -1 hi kyo le rahe hai 0 bhi to le sakte hai 0 lene pe submit to ho ja raha hai but run time jayada aa raha hai kyo??

rohitkumarsingh
join shbcf.ru