The index of the first max in an array

Report a typo

Write a program that reads an array of ints and finds the index of the first maximum in that array.

Input data format

The first line contains the number of elements in the array.

The second line contains the array elements separated by spaces.

An array always has at least one element.

Output data format

Only a single integer value: the index of the first maximum.

Sample Input 1:

5
2 5 3 4 5

Sample Output 1:

1

Sample Input 2:

6
1000 10 1000 10 10 1001

Sample Output 2:

5
Write a program in Java 17
class Main {
public static void main(String[] args) {
// put your code here
}
}
___

Create a free account to access the full topic