Skip to content

Commit ad3cf0c

Browse files
authored
Merge pull request BeeBombshell#121 from chickenCHRISpy/chris-dsa-hacktoberfest
added a classic dsa problem
2 parents 1330553 + 3d5a5da commit ad3cf0c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

DSA/find_Insert_position.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
# Function to find insert position of K
4+
def find_index(arr, n, K):
5+
6+
for i in range(n):
7+
if arr[i] == K:
8+
return i
9+
10+
elif arr[i] > K:
11+
return i
12+
13+
return n
14+
15+
arr = [1, 3, 5, 6, 8]
16+
n = len(arr)
17+
K = 2
18+
print(find_index(arr, n, K))

0 commit comments

Comments
 (0)