Hi, guys!
Where is my mistake?
Thank you in advance!
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
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList();
for (int i = 0; i < 10; i++) {
list.add(Integer.parseInt(reader.readLine()));
}
int count = 1;
int[] arr = new int[10];
for (int i = 0; i < 9; i++) {
if (list.get(i).equals(list.get(i+1))) {
arr[i] = count;
count++;
}
}
int max = arr[0];
for (int i = 0; i < 10; i++) {
if (arr[i] > max) max = arr[i];
}
System.out.println(max);
}
}
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
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList();
for (int i = 0; i < 10; i++) {
list.add(Integer.parseInt(reader.readLine()));
}
int count = 1;
int[] arr = new int[10];
for (int i = 0; i < 9; i++) {
if (list.get(i).equals(list.get(i+1))) {
arr[i] = count;
count++;
}
}
int max = arr[0];
for (int i = 0; i < 10; i++) {
if (arr[i] > max) max = arr[i];
}
System.out.println(max);
}
}