The test case is: 89, 12, 12, 98, 111, 42, 98, 98, 98, 71
The value should be 3 right ? because the longest sequence of repeating numbers is three 98.
Thank you for your time for reviewing my code.
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 scanner = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 10; i++) {
int input = scanner.nextInt();
list.add(input);
}
int max = 0;
int count = 1;
for (int i = 0; i < list.size() - 1; i++) {
if (list.get(i) == list.get(i + 1)) {
count++;
}
else if (count > max){
max = count;
count = 1;
}
}
System.out.println(max);
}
}