-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1056-ConfusingNumber.cs
38 lines (33 loc) · 962 Bytes
/
1056-ConfusingNumber.cs
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
//-----------------------------------------------------------------------------
// Runtime: 36ms
// Memory Usage: 14.7 MB
// Link: https://leetcode.com/submissions/detail/344764388/
//-----------------------------------------------------------------------------
using System.Collections.Generic;
namespace LeetCode
{
public class _1056_ConfusingNumber
{
public bool ConfusingNumber(int N)
{
var map = new Dictionary<int, int>()
{
{ 0, 0 },
{ 1, 1 },
{ 6, 9 },
{ 8, 8 },
{ 9, 6 },
};
var num = N;
var revert = 0;
while (num > 0)
{
var digit = num % 10;
if (!map.ContainsKey(digit)) return false;
revert = revert * 10 + map[digit];
num /= 10;
}
return revert != N;
}
}
}