MCPcopy Create free account
hub / github.com/BeeBombshell/Python-DSA / find_index

Function find_index

DSA/find_Insert_position.py:4–13  ·  view source on GitHub ↗
(arr, n, K)

Source from the content-addressed store, hash-verified

2
3# Function to find insert position of K
4def 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
15arr = [1, 3, 5, 6, 8]
16n = len(arr)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected