I insert numbers and get the correct output, would anyone tell me why I'm failing the last task?
package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
/*
Longest sequence
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add(Integer.parseInt(reader.readLine()));
}
int counter = 1;
int rep = 1;
for (int i = 0; i < list.size() - 1; i++) {
if (list.get(i) == list.get(i + 1)) {
rep++;
if (rep > counter) {
counter = rep;
}
} else if (list.get(i) != list.get(i + 1)) {
rep = 1;
}
}
System.out.println(counter);
}
}