|
1 | | -<h2><a href="https://leetcode.com/problems/binary-search/">704. Binary Search</a></h2><h3>Easy</h3><hr><div><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> |
| 1 | +<h2><a href="https://leetcode.com/problems/binary-search">792. 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 | 2 |
|
3 | 3 | <p>You must write an algorithm with <code>O(log n)</code> runtime complexity.</p> |
4 | 4 |
|
5 | 5 | <p> </p> |
6 | 6 | <p><strong class="example">Example 1:</strong></p> |
7 | 7 |
|
8 | | -<pre><strong>Input:</strong> nums = [-1,0,3,5,9,12], target = 9 |
| 8 | +<pre> |
| 9 | +<strong>Input:</strong> nums = [-1,0,3,5,9,12], target = 9 |
9 | 10 | <strong>Output:</strong> 4 |
10 | 11 | <strong>Explanation:</strong> 9 exists in nums and its index is 4 |
11 | 12 | </pre> |
12 | 13 |
|
13 | 14 | <p><strong class="example">Example 2:</strong></p> |
14 | 15 |
|
15 | | -<pre><strong>Input:</strong> nums = [-1,0,3,5,9,12], target = 2 |
| 16 | +<pre> |
| 17 | +<strong>Input:</strong> nums = [-1,0,3,5,9,12], target = 2 |
16 | 18 | <strong>Output:</strong> -1 |
17 | 19 | <strong>Explanation:</strong> 2 does not exist in nums so return -1 |
18 | 20 | </pre> |
|
26 | 28 | <li>All the integers in <code>nums</code> are <strong>unique</strong>.</li> |
27 | 29 | <li><code>nums</code> is sorted in ascending order.</li> |
28 | 30 | </ul> |
29 | | -</div> |
|
0 commit comments