Is there anything wrong in my logic? please help.
package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Longest sequence
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader buf = new BufferedReader( new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<Integer>();
for( int i =0; i < 10 ; i++ ) {
list.add(Integer.parseInt(buf.readLine()));
}
int count = 1;
int [] list2 = new int [10];
for( int i = 0; i < 10 ; i++) {
for (int j = i + 1; j < 10 ; j++) {
if(list.get(i).equals(list.get(j))) list2[i] = count++;
else {
break;
}
}
count = 1;
}
int max = list2[0];
for(int i = 1 ; i < 10 ;i++) {
if( max <= list2[i]) list2[i] = max;
}
System.out.println(max);
}
}