I know that my code isn't the most eye pleasing code you could write, but it works and the output is 100% right. Where's the issue?
package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.*;
/*
Longest sequence
*/
public class Solution {
public static void main(String[] args) throws IOException {
Scanner s = new Scanner(System.in);
ArrayList<Integer> arr = new ArrayList<Integer>();
for (int i = 0; i < 10; i++) {
arr.add(s.nextInt());
}
ArrayList<Integer> arr2 = new ArrayList<Integer>();
int count = 0;
int finale = 0;
for (int i = 0; i < arr.size(); i++) {
if (i == 0) {
int a = arr.get(i);
int b = arr.get(i +1);
if ( a== b) {
count++;
}
if (count > finale) {
finale = count;
}
}
else if (i > 0 && i < arr.size()-1) {
int a = arr.get(i);
int b = arr.get(i + 1);
int c = arr.get(i - 1);
if ((a == b) || (a ==c && c !=0)) {
count++;
if (count > finale) {
finale = count;
}
if (a!=b) {
count = 0;
}
}
}
else if (i == arr.size()-1) {
int a = arr.get(i);
int c = arr.get(i -1);
if (a == c) {
count++;
}
if (count > finale) {
finale = count;
}
}
}
System.out.println(finale);
}
}