Hey, I can't seem to figure out why the last condition is not validated, I know doing the comparison of i and i+1 doesn't return the right number, but lastly I increase it by 1 and it should get it right. The output is correct for the input given. Thank you!
package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
/*
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 maxCount = 0, count = 0;
for(int i=0; i<9; i++) {
if(list.get(i).equals(list.get(i+1))){
count++;
} else {
if(count > maxCount) {
maxCount = count;
}
count = 0;
}
}
maxCount++;
System.out.println(maxCount);
}
}