Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)

AltStyle によって変換されたページ (->オリジナル) /