I tried so many times with different inputs, every time it's right, but I can't pass the last condition. Any advice? I tried a different approach :)
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 {
//write your code her
Scanner scan = new Scanner(System.in);
ArrayList<Integer> nums = new ArrayList<Integer>();
for(int i = 0; i < 10; i++){
nums.add(Integer.parseInt(scan.nextLine()));
}
HashSet<Integer> hashNum = new HashSet<Integer>(nums);
int counter = 0;
int max = 0;
for(int num : hashNum){
counter = Collections.frequency(nums, num);
if(counter > max) max = counter;
}
System.out.println(max);
}
}