Skip to content

Commit 1ede581

Browse files
committed
Create README - LeetHub
1 parent f2fb00e commit 1ede581

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

0278-first-bad-version/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<h2><a href="https://leetcode.com/problems/first-bad-version/">278. First Bad Version</a></h2><h3>Easy</h3><hr><div><p>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.</p>
2+
3+
<p>Suppose you have <code>n</code> versions <code>[1, 2, ..., n]</code> and you want to find out the first bad one, which causes all the following ones to be bad.</p>
4+
5+
<p>You are given an API <code>bool isBadVersion(version)</code> which returns whether <code>version</code> is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre><strong>Input:</strong> n = 5, bad = 4
11+
<strong>Output:</strong> 4
12+
<strong>Explanation:</strong>
13+
call isBadVersion(3) -&gt; false
14+
call isBadVersion(5)&nbsp;-&gt; true
15+
call isBadVersion(4)&nbsp;-&gt; true
16+
Then 4 is the first bad version.
17+
</pre>
18+
19+
<p><strong class="example">Example 2:</strong></p>
20+
21+
<pre><strong>Input:</strong> n = 1, bad = 1
22+
<strong>Output:</strong> 1
23+
</pre>
24+
25+
<p>&nbsp;</p>
26+
<p><strong>Constraints:</strong></p>
27+
28+
<ul>
29+
<li><code>1 &lt;= bad &lt;= n &lt;= 2<sup>31</sup> - 1</code></li>
30+
</ul>
31+
</div>

0 commit comments

Comments
 (0)