|
3 | 3 | importjava.util.HashMap;
|
4 | 4 | importjava.util.Map;
|
5 | 5 |
|
6 |
| -/** |
7 |
| - * 1056. Confusing Number |
8 |
| - * |
9 |
| - * Given a number N, return true if and only if it is a confusing number, which satisfies the following condition: |
10 |
| - * We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, |
11 |
| - * they become 0, 1, 9, 8, 6 respectively. When 2, 3, 4, 5 and 7 are rotated 180 degrees, |
12 |
| - * they become invalid. A confusing number is a number that when rotated 180 degrees becomes a different number with each digit valid. |
13 |
| - * |
14 |
| - * Example 1: |
15 |
| - * Input: 6 |
16 |
| - * Output: true |
17 |
| - * Explanation: |
18 |
| - * We get 9 after rotating 6, 9 is a valid number and 9!=6. |
19 |
| - * |
20 |
| - * |
21 |
| - * Example 2: |
22 |
| - * Input: 89 |
23 |
| - * Output: true |
24 |
| - * Explanation: |
25 |
| - * We get 68 after rotating 89, 86 is a valid number and 86!=89. |
26 |
| - * |
27 |
| - * |
28 |
| - * Example 3: |
29 |
| - * Input: 11 |
30 |
| - * Output: false |
31 |
| - * Explanation: |
32 |
| - * We get 11 after rotating 11, 11 is a valid number but the value remains the same, thus 11 is not a confusing number. |
33 |
| - * |
34 |
| - * Example 4: |
35 |
| - * Input: 25 |
36 |
| - * Output: false |
37 |
| - * Explanation: |
38 |
| - * We get an invalid number after rotating 25. |
39 |
| - * |
40 |
| - * Note: |
41 |
| - * |
42 |
| - * 0 <= N <= 10^9 |
43 |
| - * After the rotation we can ignore leading zeros, for example if after rotation we have 0008 then this number is considered as just 8.*/ |
44 | 6 | publicclass_1056 {
|
45 | 7 | publicstaticclassSolution1 {
|
46 |
| -Map<Integer,Integer>map =newHashMap<Integer,Integer>() {{ |
47 |
| -put(0,0); |
48 |
| -put(1,1); |
49 |
| -put(8,8); |
50 |
| -put(6,9); |
51 |
| -put(9,6); |
52 |
| - } |
| 8 | +Map<Integer,Integer>map =newHashMap<Integer,Integer>() { |
| 9 | + { |
| 10 | +put(0,0); |
| 11 | +put(1,1); |
| 12 | +put(8,8); |
| 13 | +put(6,9); |
| 14 | +put(9,6); |
| 15 | + } |
53 | 16 | };
|
54 | 17 |
|
55 | 18 | publicbooleanconfusingNumber(intN) {
|
|