Skip to content

Commit 815139c

Browse files
committed
Create README - LeetHub
1 parent a6d3217 commit 815139c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

search-insert-position/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<h2>35. Search Insert Position</h2><h3>Easy</h3><hr><div><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>
2+
3+
<p>You must&nbsp;write an algorithm with&nbsp;<code>O(log n)</code> runtime complexity.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong>Example 1:</strong></p>
7+
<pre><strong>Input:</strong> nums = [1,3,5,6], target = 5
8+
<strong>Output:</strong> 2
9+
</pre><p><strong>Example 2:</strong></p>
10+
<pre><strong>Input:</strong> nums = [1,3,5,6], target = 2
11+
<strong>Output:</strong> 1
12+
</pre><p><strong>Example 3:</strong></p>
13+
<pre><strong>Input:</strong> nums = [1,3,5,6], target = 7
14+
<strong>Output:</strong> 4
15+
</pre><p><strong>Example 4:</strong></p>
16+
<pre><strong>Input:</strong> nums = [1,3,5,6], target = 0
17+
<strong>Output:</strong> 0
18+
</pre><p><strong>Example 5:</strong></p>
19+
<pre><strong>Input:</strong> nums = [1], target = 0
20+
<strong>Output:</strong> 0
21+
</pre>
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] &lt;= 10<sup>4</sup></code></li>
28+
<li><code>nums</code> contains <strong>distinct</strong> values sorted in <strong>ascending</strong> order.</li>
29+
<li><code>-10<sup>4</sup> &lt;= target &lt;= 10<sup>4</sup></code></li>
30+
</ul>
31+
</div>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy