Hi,
I don't understand why my code doesn't work.
I guess it's because I used Integer (which we have to use) but I don't know how to bypass it.
I tried to change Integer by Long, but it didn't work.
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 {
ArrayList<Integer> list = new ArrayList<Integer>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < 10; i++){
list.add(Integer.parseInt(reader.readLine()));
}
int maxLength = 1;
for(int i = 0; i < 9; i++){
int maxCurrentNumberLength = 1;
if(list.get(i) == list.get(i + 1)){
for(int j = i + 1; j < list.size(); j++){
if(list.get(j) == list.get(i)){
maxCurrentNumberLength ++;
}
else {
break;
}
}
}
if(maxCurrentNumberLength > maxLength){
maxLength = maxCurrentNumberLength;
}
}
System.out.println(maxLength);
}
}