The maximum product of adjacent elements

Report a typo

Write a program that reads an array of ints and outputs the maximum product of two adjacent elements in the given array of non-negative numbers.

Think about iterating through the array and comparing the product of each pair of adjacent elements. Keep track of the maximum product found so far. You can initialize a variable to store the maximum product.

Input data format

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

The second line contains the elements of the array separated by spaces.

The array always has at least two elements.

Sample Input 1:

2
5 3

Sample Output 1:

15

Sample Input 2:

3
10 8 4

Sample Output 2:

80
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