Hi,
as hint in the validation it says: "Check, if the length of the longest sequence is also calculated correctly if it is at the end of the list of entered numbers." Checked it manually, and it works as it should. Does anyone has an idea? Thx
package de.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
/*
Längste Sequenz
*/
public class Solution {
public static void main(String[] args) throws IOException {
//schreib hier deinen Code
int k = 1;
int max = 1;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 10; i++) {
list.add(Integer.parseInt(reader.readLine()));
}
// Collections.sort(list);
for (int i = 0; i < list.size()-1; i++) {
int j = i + 1;
if (list.get(i).equals(list.get(j))) {
k++;
}
if (max < k) {
max = k;
}
else {
k = 1;
}
}
System.out.println(max);
}
}