I think my code is correct
and its output
3
plz tell me what is fault....
thanks
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
ArrayList<Integer> list = new ArrayList<Integer>();
ArrayList<Integer> num = new ArrayList<Integer>();
int max = 0;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0 ; i < 10; i++)
{
int a = Integer.parseInt(reader.readLine());
list.add(a);
}
for (int i = 0 ; i < list.size()-1; i++)
{
if (list.get(i) == list.get(i + 1)) max++;
else{
num.add(max);
max = 0;
}
}
for (int i =0; i < num.size();i++)
{
max = num.get(0);
max = num.get(i) > max ? num.get(i) :max;
if(i== num.size()-1)
System.out.println(max+1);
}
}
}