|
3 | 3 | [中文文档](/solution/1000-1099/1056.Confusing%20Number/README.md)
|
4 | 4 |
|
5 | 5 | ## Description
|
6 |
| -None |
| 6 | +<p>Given a number <code>N</code>, return <code>true</code> if and only if it is a <em>confusing number</em>, which satisfies the following condition:</p> |
| 7 | + |
| 8 | +<p>We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. When 2, 3, 4, 5 and 7 are rotated 180 degrees, they become invalid. A <em>confusing number</em> is a number that when rotated 180 degrees becomes a <strong>different</strong> number with each digit valid.</p> |
| 9 | + |
| 10 | +<p> </p> |
| 11 | + |
| 12 | +<p><strong>Example 1:</strong></p> |
| 13 | + |
| 14 | +<p><img alt="" src="https://assets.leetcode.com/uploads/2019/03/23/1268_1.png" style="width: 180px; height: 90px;" /></p> |
| 15 | + |
| 16 | +<pre> |
| 17 | +<strong>Input: </strong><span id="example-input-1-1">6</span> |
| 18 | +<strong>Output: </strong><span id="example-output-1">true</span> |
| 19 | +<strong>Explanation: </strong> |
| 20 | +We get <code>9</code> after rotating <code>6</code>, <code>9</code> is a valid number and <code>9!=6</code>. |
| 21 | +</pre> |
| 22 | + |
| 23 | +<p><strong>Example 2:</strong></p> |
| 24 | + |
| 25 | +<p><img alt="" src="https://assets.leetcode.com/uploads/2019/03/23/1268_2.png" style="width: 180px; height: 90px;" /></p> |
| 26 | + |
| 27 | +<pre> |
| 28 | +<strong>Input: </strong><span id="example-input-2-1">89</span> |
| 29 | +<strong>Output: </strong><span id="example-output-2">true</span> |
| 30 | +<strong>Explanation: </strong> |
| 31 | +We get <code>68</code> after rotating <code>89</code>, <code>86</code> is a valid number and <code>86!=89</code>. |
| 32 | +</pre> |
| 33 | + |
| 34 | +<p><strong>Example 3:</strong></p> |
| 35 | + |
| 36 | +<p><img alt="" src="https://assets.leetcode.com/uploads/2019/03/26/1268_3.png" style="width: 301px; height: 121px;" /></p> |
| 37 | + |
| 38 | +<pre> |
| 39 | +<strong>Input: </strong><span id="example-input-3-1">11</span> |
| 40 | +<strong>Output: </strong><span id="example-output-3">false</span> |
| 41 | +<strong>Explanation: </strong> |
| 42 | +We get <code>11</code> after rotating <code>11</code>, <code>11</code> is a valid number but the value remains the same, thus <code>11</code> is not a confusing number. |
| 43 | +</pre> |
| 44 | + |
| 45 | +<p><strong>Example 4:</strong></p> |
| 46 | + |
| 47 | +<p><img alt="" src="https://assets.leetcode.com/uploads/2019/03/23/1268_4.png" style="width: 180px; height: 90px;" /></p> |
| 48 | + |
| 49 | +<pre> |
| 50 | +<strong>Input: </strong><span id="example-input-4-1">25</span> |
| 51 | +<strong>Output: </strong><span id="example-output-4">false</span> |
| 52 | +<strong>Explanation: </strong> |
| 53 | +We get an invalid number after rotating <code>25</code>. |
| 54 | +</pre> |
| 55 | + |
| 56 | +<p> </p> |
| 57 | + |
| 58 | +<p><strong>Note:</strong></p> |
| 59 | + |
| 60 | +<ol> |
| 61 | + <li><code>0 <= N <= 10^9</code></li> |
| 62 | + <li>After the rotation we can ignore leading zeros, for example if after rotation we have <code>0008</code> then this number is considered as just <code>8</code>.</li> |
| 63 | +</ol> |
7 | 64 |
|
8 | 65 |
|
9 | 66 | ## Solutions
|
|
0 commit comments