The first index of a sublist

Report a typo

Write a program that reads two sequences of numbers and outputs the starting positions of the first and the last occurrences of the second sequence within the first one, or -1 if there is no such occurrence. Numbers must be separated by a space.

Sample Input 1:

2 1 2 3 4 1 2 3
1 2 3

Sample Output 1:

1 5

Sample Input 2:

77 2 4 112 3
104

Sample Output 2:

-1 -1

Sample Input 3:

1
1

Sample Output 3:

0 0
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