I can't figure out the logic to get the answer to 3 and still have the loop output 1 if all the numbers are non-sequential.
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 {
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
ArrayList <Integer> list = new ArrayList<Integer>();
for (int i = 0; i<10; i++){
int a = Integer.parseInt(br.readLine());
list.add(a);
}
int countB = 1;
int countA = 1;
for (int i=0; i<list.size()-1; i++){
if (countB<countA)
countB=countA;
if (list.get(i).equals(list.get(i+1)))
countA++;
if (countB>countA)
countA=1;
}
System.out.println(countB);
}//write your code here
}