Check if an array contains two numbers

Report a typo
Write a program that reads an unsorted array of integers and two numbers n and m. The program must check if n and m occur next to each other in the array (in any order).

Input data format

The first line contains the size of an array.
The second line contains elements of the array.
The third line contains two integer numbers n and m.
All numbers in the same line are separated by the space character.

Output data format

Only a single value: true or false.

Sample Input 1:

3
1 3 2
2 3

Sample Output 1:

true

Sample Input 2:

3
2 1 2
2 3

Sample Output 2:

false
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