-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c66885c
commit 30e6694
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<h2><a href="https://leetcode.com/problems/search-insert-position">35. Search Insert Position</a></h2><h3>Easy</h3><hr><p>Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.</p> | ||
|
||
<p>You must write an algorithm with <code>O(log n)</code> runtime complexity.</p> | ||
|
||
<p> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> nums = [1,3,5,6], target = 5 | ||
<strong>Output:</strong> 2 | ||
</pre> | ||
|
||
<p><strong class="example">Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> nums = [1,3,5,6], target = 2 | ||
<strong>Output:</strong> 1 | ||
</pre> | ||
|
||
<p><strong class="example">Example 3:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> nums = [1,3,5,6], target = 7 | ||
<strong>Output:</strong> 4 | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= nums.length <= 10<sup>4</sup></code></li> | ||
<li><code>-10<sup>4</sup> <= nums[i] <= 10<sup>4</sup></code></li> | ||
<li><code>nums</code> contains <strong>distinct</strong> values sorted in <strong>ascending</strong> order.</li> | ||
<li><code>-10<sup>4</sup> <= target <= 10<sup>4</sup></code></li> | ||
</ul> |