-
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.
Add LeetCode #35 'Search Insert Position' [Easy].
- Loading branch information
1 parent
c410517
commit a985643
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...rc/LeetCode.Challenges/Problems00xx/N_0035_SearchInsertPosition/_Description.md
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,30 @@ | ||
# Search Insert Position (#35) | ||
|
||
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. | ||
|
||
**You must write an algorithm with O(log n) runtime complexity.** | ||
|
||
## Examples | ||
|
||
### Example 1: | ||
|
||
Input: nums = [1,3,5,6], target = 5 | ||
Output: 2 | ||
|
||
### Example 2: | ||
|
||
Input: nums = [1,3,5,6], target = 2 | ||
Output: 1 | ||
|
||
### Example 3: | ||
|
||
Input: nums = [1,3,5,6], target = 7 | ||
Output: 4 | ||
|
||
## Constraints | ||
|
||
- `1 <= nums.length <= 10^4` | ||
- `-10^4 <= nums[i] <= 10^4` | ||
- `nums` contains distinct values sorted in ascending order. | ||
- `-10^4 <= target <= 10^4` |