import
java.util.*;
class
GFG {
public
static
void
nums_with_least_occurrence(
int
A[],
int
K)
{
Map<Integer, Integer> hashmp
=
new
HashMap<Integer, Integer>();
for
(
int
i =
0
; i < A.length; i++) {
if
(hashmp.containsKey(A[i])) {
hashmp.put(A[i],
hashmp.get(A[i]) +
1
);
}
else
{
hashmp.put(A[i],
1
);
}
}
int
mini_occurrence = Integer.MAX_VALUE;
for
(Map.Entry<Integer, Integer> entry :
hashmp.entrySet()) {
if
(entry.getValue() < mini_occurrence)
mini_occurrence = entry.getValue();
}
ArrayList<Integer> ans =
new
ArrayList<Integer>();
for
(Map.Entry<Integer, Integer> entry :
hashmp.entrySet()) {
if
(entry.getValue() >= K * mini_occurrence)
ans.add(entry.getKey());
}
if
(ans.isEmpty())
System.out.println(
"No elements found"
);
else
{
for
(
int
i =
0
; i < ans.size(); i++)
System.out.print(ans.get(i) +
" "
);
}
System.out.println();
}
public
static
void
main(String[] args)
{
int
[] A = {
4
,
4
,
3
,
6
,
6
,
6
,
8
,
9
};
int
K =
2
;
nums_with_least_occurrence(A, K);
}
}