public void MajorityElement_1()
        {
            var solution = new _0229_MajorityElementII();
            var result   = solution.MajorityElement(new int[] { 3, 2, 3 });

            AssertHelper.AssertList(new int[] { 3 }, result);
        }
示例#2
0
        public void GeneratePossibleNextMoves_1()
        {
            var solution = new _0293_FlipGame();
            var result   = solution.GeneratePossibleNextMoves("++++");

            AssertHelper.AssertList(new string[] { "--++", "+--+", "++--" }, result);
        }
示例#3
0
        public void RemoveInvalidParenthesesTest_1()
        {
            var solution = new _0301_RemoveInvalidParentheses();
            var result   = solution.RemoveInvalidParentheses("()())()");

            AssertHelper.AssertList(new string[] { "(())()", "()()()" }, result);
        }
        public void TopKFrequentTest_1()
        {
            var solution = new _0347_TopKFrequentElements();
            var result   = solution.TopKFrequent(new int[] { 1, 1, 1, 2, 2, 3 }, 2);

            AssertHelper.AssertList(new int[] { 1, 2 }, result);
        }
示例#5
0
        public void PowerfulIntegers_2()
        {
            var solution = new _0970_PowerfulIntegers();
            var result   = solution.PowerfulIntegers(3, 5, 15);

            AssertHelper.AssertList(new int[] { 2, 4, 6, 8, 10, 14 }, result.OrderBy(n => n).ToList());
        }
示例#6
0
        public void CircularPermutation_1()
        {
            var solution = new _1238_CircularPermutationInBinaryRepresentation();
            var result   = solution.CircularPermutation(2, 3);

            AssertHelper.AssertList(new int[] { 3, 2, 0, 1 }, result);
        }
        public void BraceExpansionIITest_1()
        {
            var solution = new _1096_BraceExpansionII();
            var results  = solution.BraceExpansionII("{a,b}{c,{d,e}}");

            AssertHelper.AssertList(new string[] { "ac", "ad", "ae", "bc", "bd", "be" }, results);
        }
示例#8
0
        public void PartitionLabels_1()
        {
            var solution = new _0763_PartitionLabels();
            var result   = solution.PartitionLabels("ababcbacadefegdehijhklij");

            AssertHelper.AssertList(new int[] { 9, 7, 8 }, result);
        }
        public void ZigzagLevelOrder_Null()
        {
            var solution = new _103_BinaryTreeZigzagLevelOrderTraversal();
            var result   = solution.ZigzagLevelOrder(null);

            AssertHelper.AssertList(new List <IList <int> >(), result);
        }
示例#10
0
        public void SubdomainVisits_2()
        {
            var solution = new _0811_SubdomainVisitCount();
            var result   = solution.SubdomainVisits(new string[] { "900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 wiki.org" });

            AssertHelper.AssertList(new string[] { "951 com", "901 mail.com", "900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 org", "5 wiki.org" }, result);
        }
示例#11
0
        public void SubdomainVisits_1()
        {
            var solution = new _0811_SubdomainVisitCount();
            var result   = solution.SubdomainVisits(new string[] { "9001 discuss.leetcode.com" });

            AssertHelper.AssertList(new string[] { "9001 com", "9001 leetcode.com", "9001 discuss.leetcode.com" }, result);
        }
示例#12
0
        public void FindAndReplacePattern_1()
        {
            var solution = new _0890_FindAndReplacePattern();
            var result   = solution.FindAndReplacePattern(new string[] { "abc", "deq", "mee", "aqq", "dkd", "ccc" }, "abb");

            AssertHelper.AssertList(new string[] { "mee", "aqq" }, result);
        }
        public void PathInZigZagTree_1()
        {
            var solution = new _1104_PathInZigzagLabelledBinaryTree();
            var result   = solution.PathInZigZagTree(14);

            AssertHelper.AssertList(new int[] { 1, 3, 4, 14 }, result);
        }
        public void PathInZigZagTree_2()
        {
            var solution = new _1104_PathInZigzagLabelledBinaryTree();
            var result   = solution.PathInZigZagTree(26);

            AssertHelper.AssertList(new int[] { 1, 2, 6, 10, 26 }, result);
        }
示例#15
0
        public void FindItineraryTest_1()
        {
            var solution = new _0332_ReconstructItinerary();
            var result   = solution.FindItinerary(new List <IList <string> >()
            {
                new List <string>()
                {
                    "MUC", "LHR"
                },
                new List <string>()
                {
                    "JFK", "MUC"
                },
                new List <string>()
                {
                    "SFO", "SJC"
                },
                new List <string>()
                {
                    "LHR", "SFO"
                },
            });

            AssertHelper.AssertList(new string[] { "JFK", "MUC", "LHR", "SFO", "SJC" }, result);
        }
        public void PancakeSort_1()
        {
            var solution = new _0969_PancakeSorting();
            var result   = solution.PancakeSort(new int[] { 3, 2, 4, 1 });

            AssertHelper.AssertList(new int[] { 3, 4, 2, 3, 1, 2 }, result);
        }
示例#17
0
        public void CircularPermutation_2()
        {
            var solution = new _1238_CircularPermutationInBinaryRepresentation();
            var result   = solution.CircularPermutation(3, 2);

            AssertHelper.AssertList(new int[] { 2, 3, 1, 0, 4, 5, 7, 6 }, result);
        }
示例#18
0
        public void IpToCIDR_1()
        {
            var solution = new _0751_IPToCIDR();
            var result   = solution.IpToCIDR("255.0.0.7", 10);

            AssertHelper.AssertList(new string[] { "255.0.0.7/32", "255.0.0.8/29", "255.0.0.16/32" }, result);
        }
        public void BraceExpansionIITest_2()
        {
            var solution = new _1096_BraceExpansionII();
            var results  = solution.BraceExpansionII("{{a,z},a{b,c},{ab,z}}");

            AssertHelper.AssertList(new string[] { "a", "ab", "ac", "z" }, results);
        }
示例#20
0
        public void TopKFrequent_2()
        {
            var solution = new _0692_TopKFrequentWords();
            var result   = solution.TopKFrequent(new string[] { "the", "day", "is", "sunny", "the", "the", "the", "sunny", "is", "is" }, 4);

            AssertHelper.AssertList(new string[] { "the", "is", "sunny", "day" }, result);
        }
        public void GenerateTest_0()
        {
            var solution = new _119_PascalsTriangle2();
            var result   = solution.GetRow(0);

            AssertHelper.AssertList(new int[] { 1 }, result);
        }
示例#22
0
        public void TopKFrequent_1()
        {
            var solution = new _0692_TopKFrequentWords();
            var result   = solution.TopKFrequent(new string[] { "i", "love", "leetcode", "i", "love", "coding" }, 2);

            AssertHelper.AssertList(new string[] { "i", "love" }, result);
        }
        public void CrawlTest_1()
        {
            var parser = new HtmlParser(new List <string>()
            {
                "http://news.yahoo.com",
                "http://news.yahoo.com/news",
                "http://news.yahoo.com/news/topics/",
                "http://news.google.com",
                "http://news.yahoo.com/us"
            }, new List <int[]>()
            {
                new int[] { 2, 0 },
                new int[] { 2, 1 },
                new int[] { 3, 2 },
                new int[] { 3, 1 },
                new int[] { 0, 4 },
            });

            var solution = new _1242_WebCrawlerMultithreaded();
            var result   = solution.Crawl("http://news.yahoo.com/news/topics/", parser);

            AssertHelper.AssertList(new string[] {
                "http://news.yahoo.com/news/topics/",
                "http://news.yahoo.com",
                "http://news.yahoo.com/news",
                "http://news.yahoo.com/us"
            }, result);
        }
        public void FindLaddersTest_2()
        {
            var solution = new _0126_WordLadderII();
            var result   = solution.FindLadders("hit", "cog", new string[] { "hot", "dot", "dog", "lot", "log" });

            AssertHelper.AssertList(new List <IList <string> >(), result);
        }
示例#25
0
        public void PowerfulIntegers_1()
        {
            var solution = new _0970_PowerfulIntegers();
            var result   = solution.PowerfulIntegers(2, 3, 10);

            AssertHelper.AssertList(new int[] { 2, 3, 4, 5, 7, 9, 10 }, result.OrderBy(n => n).ToList());
        }
        public void SelfDividingNumbers_2()
        {
            var solution = new _0728_SelfDividingNumbers();
            var result   = solution.SelfDividingNumbers(1, 22);

            AssertHelper.AssertList(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22 }, result);
        }
        public void LevelOrderBottomTest_Null()
        {
            var solution = new _107_BinaryTreeLevelOrderTraversal2();
            var result   = solution.LevelOrderBottom(null);

            AssertHelper.AssertList(new List <IList <int> >(), result);
        }
        public void SelfDividingNumbers_1()
        {
            var solution = new _0728_SelfDividingNumbers();
            var result   = solution.SelfDividingNumbers(128, 128);

            AssertHelper.AssertList(new int[] { 128 }, result);
        }
        public void ReadBinaryWatch_1()
        {
            var solution = new _0401_BinaryWatch();
            var result   = solution.ReadBinaryWatch(1);

            AssertHelper.AssertList(new string[] { "0:01", "0:02", "0:04", "0:08", "0:16", "0:32", "1:00", "2:00", "4:00", "8:00" }, result);
        }
示例#30
0
        public void FindAllConcatenatedWordsInADict_1()
        {
            var solution = new _0472_ConcatenatedWords();
            var result   = solution.FindAllConcatenatedWordsInADict(new string[] { "cat", "cats", "catsdogcats", "dog", "dogcatsdog", "hippopotamuses", "rat", "ratcatdogcat" });

            AssertHelper.AssertList(new string[] { "catsdogcats", "dogcatsdog", "ratcatdogcat" }, result);
        }