Skip to content

Commit ba34bca

Browse files
committed
Create README - LeetHub
1 parent 1eaebf9 commit ba34bca

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

0704-binary-search/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<h2><a href="https://leetcode.com/problems/binary-search">704. Binary Search</a></h2><h3>Easy</h3><hr><p>Given an array of integers <code>nums</code> which is sorted in ascending order, and an integer <code>target</code>, write a function to search <code>target</code> in <code>nums</code>. If <code>target</code> exists, then return its index. Otherwise, return <code>-1</code>.</p>
2+
3+
<p>You must write an algorithm with <code>O(log n)</code> runtime complexity.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> nums = [-1,0,3,5,9,12], target = 9
10+
<strong>Output:</strong> 4
11+
<strong>Explanation:</strong> 9 exists in nums and its index is 4
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> nums = [-1,0,3,5,9,12], target = 2
18+
<strong>Output:</strong> -1
19+
<strong>Explanation:</strong> 2 does not exist in nums so return -1
20+
</pre>
21+
22+
<p>&nbsp;</p>
23+
<p><strong>Constraints:</strong></p>
24+
25+
<ul>
26+
<li><code>1 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
27+
<li><code>-10<sup>4</sup> &lt; nums[i], target &lt; 10<sup>4</sup></code></li>
28+
<li>All the integers in <code>nums</code> are <strong>unique</strong>.</li>
29+
<li><code>nums</code> is sorted in ascending order.</li>
30+
</ul>

0 commit comments

Comments
 (0)