Be sure that the length of the longest sequence is calculated correctly when it is located at the end of the list of entered numbers.
package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
/*
Longest sequence
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
Scanner sc = new Scanner(System.in);
ArrayList<Integer> arrayList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
arrayList.add(sc.nextInt());
}
int max = 0;
int count = 1;
for (int i = 1; i < arrayList.size(); i++) {
if (arrayList.get(i).equals(arrayList.get(i-1))) {
count++;
}
if (count > max) max = count;
}
System.out.println(max);
}
}