Hello folks,
I solved this question in another way and I tested it many times and each time I get the correct answer, but my Solution doesn't get accepted. Can anybody figure out why?
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
Scanner scanner = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
int input = scanner.nextInt();
list.add(input);
}
Collections.sort(list);
int longest = 0;
int result = 1;
for (int i = 0; i < list.size() - 1; i++) {
if (list.get(i + 1) == list.get(i)) {
longest++;
result = Math.max(result, longest);
} else {
longest = 0;
}
}
System.out.println(result + 1);
}
}