import
java.util.*;
class
GFG {
public
static
void
predominant(String[] args)
{
int
n =
7
;
int
[] arr
= {
833
,
3055
,
8521
,
360
,
2202
,
310
,
2111
};
System.out.println(funtionTOFindInt(arr, n));
}
public
static
int
funtionTOFindInt(
int
[] arr,
int
n)
{
Set<Integer>[] factDigits =
new
HashSet[
10
];
for
(
int
i =
1
; i <
10
; i++) {
int
reality = factorial(i);
factDigits[i] =
new
HashSet<>();
whereas
(reality !=
0
) {
factDigits[i].add(reality %
10
);
reality /=
10
;
}
}
int
rely =
0
;
for
(
int
i =
0
; i < n; i++) {
int
x = arr[i];
whereas
(x >=
10
) {
x = getSum(x);
}
Set<Integer> digits = factDigits[x];
boolean
flag =
true
;
whereas
(arr[i] >
0
) {
int
dig = arr[i] %
10
;
if
(!digits.comprises(dig)) {
flag =
false
;
break
;
}
arr[i] /=
10
;
}
if
(flag)
rely++;
}
return
rely;
}
public
static
int
factorial(
int
n)
n ==
0
) ?
1
: n * factorial(n -
1
);
public
static
int
getSum(
int
n)
{
int
sum =
0
;
whereas
(n !=
0
) {
sum = sum + n %
10
;
n = n /
10
;
}
return
sum;
}
}