-
Notifications
You must be signed in to change notification settings - Fork 7
/
Program.cs
35 lines (32 loc) · 796 Bytes
/
Program.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
using System;
using System.Collections.Generic;
namespace StrobogrammaticNumber
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
public bool IsStrobogrammatic(string num)
{
var dict = new Dictionary<char, char>
{
{'0', '0'},
{'1', '1'},
{'6', '9'},
{'8', '8'},
{'9', '6'}
};
int li = 0, hi = num.Length - 1;
while (li <= hi)
{
if (!dict.ContainsKey(num[li]) || dict[num[li]] != num[hi])
return false;
li++;
hi--;
}
return true;
}
}
}