- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1056.java
38 lines (35 loc) · 1.01 KB
/
_1056.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
packagecom.fishercoder.solutions.secondthousand;
importjava.util.HashMap;
importjava.util.Map;
publicclass_1056 {
publicstaticclassSolution1 {
Map<Integer, Integer> map =
newHashMap<Integer, Integer>() {
{
put(0, 0);
put(1, 1);
put(8, 8);
put(6, 9);
put(9, 6);
}
};
publicbooleanconfusingNumber(intN) {
if (N == 0) {
returnfalse;
}
intnewNumber = 0;
intoriginalN = N;
while (N != 0) {
newNumber *= 10;
intdigit = N % 10;
if (!map.containsKey(digit)) {
returnfalse;
}
digit = map.get(digit);
newNumber += digit;
N /= 10;
}
returnnewNumber != originalN;
}
}
}