Пример #1
0
        public void TestCase3()
        {
            var tickets = new List <IList <string> >()
            {
                new List <string>()
                {
                    "JFK", "AAA"
                },
                new List <string>()
                {
                    "AAA", "JFK"
                },
                new List <string>()
                {
                    "JFK", "BBB"
                },
                new List <string>()
                {
                    "JFK", "CCC"
                },
                new List <string>()
                {
                    "CCC", "JFK"
                }
            };

            var itineraryReconstructor = new ReconstructItinerary();

            Assert.Equal(new[] { "JFK", "AAA", "JFK", "CCC", "JFK", "BBB" }, itineraryReconstructor.FindItinerary(tickets));
        }
Пример #2
0
        public void TestCase0()
        {
            var tickets = new List <IList <string> >()
            {
                new List <string>()
                {
                    "MUC", "LHR"
                },
                new List <string>()
                {
                    "JFK", "MUC"
                },
                new List <string>()
                {
                    "SFO", "SJC"
                },
                new List <string>()
                {
                    "LHR", "SFO"
                },
            };

            var itineraryReconstructor = new ReconstructItinerary();

            Assert.Equal(new [] { "JFK", "MUC", "LHR", "SFO", "SJC" }, itineraryReconstructor.FindItinerary(tickets));
        }
Пример #3
0
        public void TestCase4()
        {
            var tickets = new List <IList <string> >()
            {
                new List <string>()
                {
                    "EZE", "AXA"
                },
                new List <string>()
                {
                    "TIA", "ANU"
                },
                new List <string>()
                {
                    "ANU", "JFK"
                },
                new List <string>()
                {
                    "JFK", "ANU"
                },
                new List <string>()
                {
                    "ANU", "EZE"
                },
                new List <string>()
                {
                    "TIA", "ANU"
                },
                new List <string>()
                {
                    "AXA", "TIA"
                },
                new List <string>()
                {
                    "TIA", "JFK"
                },
                new List <string>()
                {
                    "ANU", "TIA"
                },
                new List <string>()
                {
                    "JFK", "TIA"
                }
            };

            var itineraryReconstructor = new ReconstructItinerary();

            Assert.Equal(new[] { "JFK", "ANU", "EZE", "AXA", "TIA", "ANU", "JFK", "TIA", "ANU", "TIA", "JFK" }, itineraryReconstructor.FindItinerary(tickets));
        }
Пример #4
0
        public void Example1()
        {
            var sol = new ReconstructItinerary();

            var output = sol.FindItinerary(new[]
            {
                new [] { "MUC", "LHR" },
                new [] { "JFK", "MUC" },
                new [] { "SFO", "SJC" },
                new [] { "LHR", "SFO" }
            });

            Assert.IsNotNull(output);
            Assert.AreEqual("JFK,MUC,LHR,SFO,SJC", string.Join(",", output));
        }
Пример #5
0
        public void Example2()
        {
            var sol = new ReconstructItinerary();

            var output = sol.FindItinerary(new[]
            {
                new [] { "JFK", "SFO" },
                new [] { "JFK", "ATL" },
                new [] { "SFO", "ATL" },
                new [] { "ATL", "JFK" },
                new [] { "ATL", "SFO" }
            });

            Assert.IsNotNull(output);
            Assert.AreEqual("JFK,ATL,JFK,SFO,ATL,SFO", string.Join(",", output));
        }
Пример #6
0
        static void Main(string[] args)
        {
            //int[] vs = { 2, 7, 11, 15 };
            //int target = 9;
            //TwoSums twoSums = new TwoSums();
            //twoSums.TwoSum(vs, target);

            //int[] vs2 = { 1, 1, 0, 1, 1, 1 };
            //FindMaxConsecutive findMax = new FindMaxConsecutive();

            //findMax.FindMaxConsecutiveOnes(vs2);

            //int[][] vs3 =
            //    {
            //    new int[] { 5, 4 },
            //    new int[] { 6, 4 },
            //    new int[] { 6, 7 },
            //    new int[] { 2, 3 }
            //    };

            //int[][] vs3 =
            //    {
            //    new int[] { 4, 5 },
            //    new int[] { 6, 7 },
            //    new int[] { 2, 3 }
            //};

            //RussianDoll russianDoll = new RussianDoll();
            //russianDoll.MaxEnvelopes(vs3);

            //string[] words = { "Hello", "Alaska", "Dad", "Peace" };
            //KeybaordRow keybaordRow = new KeybaordRow();

            //keybaordRow.FindWords(words);

            ReconstructItinerary    reconstructItinerary = new ReconstructItinerary();
            IList <IList <string> > input = new List <IList <string> >();

            //input.Add(new List<string>(new string[] { "JFK", "SFO" }));
            input.Add(new List <string>(new string[] { "JFK", "ATL" }));
            input.Add(new List <string>(new string[] { "SFO", "ATL" }));
            input.Add(new List <string>(new string[] { "ATL", "JFK" }));
            input.Add(new List <string>(new string[] { "ATL", "SFO" }));
            input.Add(new List <string>(new string[] { "JFK", "SFO" }));

            reconstructItinerary.FindItinerary(input);
        }
Пример #7
0
        public void TestCase2()
        {
            var tickets = new List <IList <string> >()
            {
                new List <string>()
                {
                    "JFK", "KUL"
                },
                new List <string>()
                {
                    "JFK", "NRT"
                },
                new List <string>()
                {
                    "NRT", "JFK"
                }
            };

            var itineraryReconstructor = new ReconstructItinerary();

            Assert.Equal(new[] { "JFK", "NRT", "JFK", "KUL" }, itineraryReconstructor.FindItinerary(tickets));
        }
Пример #8
0
        public void FindItineraryTests()
        {
            ReconstructItinerary obj = new ReconstructItinerary();

            IList <IList <string> > tickets = new List <IList <string> >
            {
                new List <string> {
                    "MUC", "LHR"
                },
                new List <string> {
                    "JFK", "MUC"
                },
                new List <string> {
                    "SFO", "SJC"
                },
                new List <string> {
                    "LHR", "SFO"
                },
            };

            var x = obj.FindItinerary(tickets);

            tickets = new List <IList <string> >
            {
                new List <string> {
                    "JFK", "SFO"
                },
                new List <string> {
                    "JFK", "ATL"
                },
                new List <string> {
                    "SFO", "ATL"
                },
                new List <string> {
                    "ATL", "JFK"
                },
                new List <string> {
                    "ATL", "SFO"
                },
            };
            x = obj.FindItinerary(tickets);

            tickets = new List <IList <string> >
            {
                new List <string> {
                    "JFK", "SFO"
                },
                new List <string> {
                    "JFK", "ATL"
                },
                new List <string> {
                    "SFO", "ATL"
                },
                new List <string> {
                    "ATL", "JFK"
                },
                new List <string> {
                    "ATL", "SFO"
                },
            };
            x = obj.FindItinerary(tickets);

            tickets = new List <IList <string> >
            {
                new List <string> {
                    "JFK", "KUL"
                },
                new List <string> {
                    "JFK", "NRT"
                },
                new List <string> {
                    "NRT", "JFK"
                },
            };
            x = obj.FindItinerary(tickets);
        }