-
Notifications
You must be signed in to change notification settings - Fork 7
/
Program.cs
31 lines (30 loc) · 905 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
using System;
using System.Collections.Generic;
namespace DestinationCity
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
static string DestCity(IList<IList<string>> paths)
{
var allCities = new HashSet<string>();
var startCities = new HashSet<string>();
foreach (var path in paths)
{
if (!allCities.Contains(path[0]))
allCities.Add(path[0]);
if (!allCities.Contains(path[1]))
allCities.Add(path[1]);
if (!startCities.Contains(path[0]))
startCities.Add(path[0]);
}
foreach (var city in allCities)
if (!startCities.Contains(city))
return city;
return "";
}
}
}