Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6ad6ebe

Browse files
committed
add search insert position
1 parent 2e8a07b commit 6ad6ebe

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

1-100/35-search-insert-position.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
Author :- Rishabh Jain <contact@rishabh1403.com>
3+
Solution for :- https://leetcode.com/problems/search-insert-position/
4+
blog for this code :- https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-search-insert-position
5+
youtube video :- https://youtu.be/l2XPvyTlC6c
6+
*/
7+
8+
var searchInsert = function (nums, target) {
9+
10+
for (let index = 0; index < nums.length; index++) {
11+
if (target <= nums[index]) {
12+
return index;
13+
}
14+
}
15+
return nums.length;
16+
};

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Solutions of all the questions from Leetcode in JavaScript.
1616

1717
- 20.Valid Parentheses - [Question](https://leetcode.com/problems/valid-parentheses/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/20-valid-parentheses.js) | [Blog](https://rishabh1403.com/leetcode-solution-of-valid-parentheses-in-javascript)
1818

19+
- 35.Search Insert Position - [Question](https://leetcode.com/problems/search-insert-position/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/58-length-of-last-word.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-search-insert-position) | [Youtube Video](https://youtu.be/l2XPvyTlC6c)
20+
1921
- 58.Length of Last Word - [Question](https://leetcode.com/problems/length-of-last-word/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/58-length-of-last-word.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-length-of-last-word) | [Youtube Video](https://youtu.be/2PQ4vtnLfnw)
2022

2123
- 167.Two Sum-II - [Question](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/101-200/167-two-sum-ii.js) | [Blog](https://rishabh1403.com/leetcode-solution-of-two-sum-ii-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=MjxN8HIzIRc)

0 commit comments

Comments
 (0)