I am not able to get a correct solution for my current code.
I am using the easiest possible solution for the given problem, using an ArrayList.
Thanks in advance.
Error: It is telling me to check if my code works for numbers > 127, or not. But I have already set the data type as Integer. It's range is far greater than 127
package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
/*
Longest sequence
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i = 0; i < 10; i++) {
list.add(Integer.parseInt(br.readLine()));
}
int maxCount = 0, count = 1;
for(int i = 1; i < 10; i++) {
if(list.get(i) == list.get(i-1)) count++;
else {
maxCount = Math.max(maxCount, count);
count = 1;
}
}
System.out.println((maxCount > count)? maxCount: count);
}
}