Skip to content

Commit af3c6b9

Browse files
author
Amogh Singhal
authored
Create max_in_array.py
1 parent ded6c69 commit af3c6b9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

max_in_array.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def maxIndex(arr):
2+
max_index = 0
3+
for i in range(1, len(arr)):
4+
if arr[max_index] < arr[i]:
5+
max_index = i
6+
return max_index
7+
8+
arr = [4,5,6,7,8,1,2,11,12,13,3,9,10]
9+
res = maxIndex(arr)
10+
print("maximum element is", arr[res],"at index:", res)

0 commit comments

Comments
 (0)