public class foxyCoders {
// This class is about modifiers and packages
public static void main(String args[]) {
int[] ar = {10, 20, 20, 10, 10, 30, 50, 10, 20};
int n = 0; System.out.println(game(n, ar)); }
public static int game(int n, int[] ar) {
ArrayList<Integer> fre = new ArrayList<Integer>();
int m = 0; for(int a =0 ;a<ar.length;a++){
fre.add(ar[a]); }
Set<Integer> unique = new HashSet<Integer>(fre);
for (Integer key : unique) {
System.out.println(key + ": " + Collections.frequency(fre, key));
int count = (Collections.frequency(fre, key));
m = m + count / 2;
System.out.println(m);
}
n=m; return n; }
}// Hopes this solves your problem
No comments:
Post a Comment