Skip to content

Commit 05c725a

Browse files
refactor : search insert position (#7036)
1 parent b7ce847 commit 05c725a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Python/cp/search_insert_position.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
If not, return the index where it would be if it were inserted in order.
55
You may assume no duplicates in the array.
66
7-
Example 1:
8-
Input: [1,3,5,6], 5
9-
Output: 2
10-
117
"""
128
# taking the input from the user
139

@@ -29,3 +25,17 @@
2925
"Number not found. It can be inserted at index {}.".format(a)
3026
) # printing the target index
3127

28+
'''
29+
Time complexity : O(N)
30+
Space complexity : O(N)
31+
'''
32+
33+
'''
34+
Test Case :
35+
36+
Input:
37+
Enter the elements in the list:[1,3,5,6]
38+
Enter the Element whose index has to be found: 5
39+
Output:
40+
The number is present at the index {}. 2
41+
'''

0 commit comments

Comments
 (0)