示例#1
0
        public void SortByBits_1()
        {
            var solution = new _1356_SortIntegersByTheNumberOf1Bits();
            var result   = solution.SortByBits(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });

            AssertHelper.AssertArray(new int[] { 0, 1, 2, 4, 8, 3, 5, 6, 7 }, result);
        }
        public void CandyCrush_1()
        {
            var solution = new _0723_CandyCrush();
            var result   = solution.CandyCrush(new int[][]
            {
                new int[] { 110, 5, 112, 113, 114 },
                new int[] { 210, 211, 5, 213, 214 },
                new int[] { 310, 311, 3, 313, 314 },
                new int[] { 410, 411, 412, 5, 414 },
                new int[] { 5, 1, 512, 3, 3 },
                new int[] { 610, 4, 1, 613, 614 },
                new int[] { 710, 1, 2, 713, 714 },
                new int[] { 810, 1, 2, 1, 1 },
                new int[] { 1, 1, 2, 2, 2 },
                new int[] { 4, 1, 4, 4, 1014 },
            });

            AssertHelper.AssertArray(
                new int[][]
            {
                new int[] { 0, 0, 0, 0, 0 },
                new int[] { 0, 0, 0, 0, 0 },
                new int[] { 0, 0, 0, 0, 0 },
                new int[] { 110, 0, 0, 0, 114 },
                new int[] { 210, 0, 0, 0, 214 },
                new int[] { 310, 0, 0, 113, 314 },
                new int[] { 410, 0, 0, 213, 414 },
                new int[] { 610, 211, 112, 313, 614 },
                new int[] { 710, 311, 412, 613, 714 },
                new int[] { 810, 411, 512, 713, 1014 },
            }, result);
        }
        public void UncommonFromSentences_2()
        {
            var solution = new _0884_UncommonWordsFromTwoSentences();
            var result   = solution.UncommonFromSentences("apple apple", "banana");

            AssertHelper.AssertArray(new string[] { "banana" }, result);
        }
        public void ArrayRankTransform_1()
        {
            var solution = new _1331_RankTransformOfAnArray();
            var result   = solution.ArrayRankTransform(new int[] { 40, 10, 20, 30 });

            AssertHelper.AssertArray(new int[] { 4, 1, 2, 3 }, result);
        }
        public void ReorderLogFilesTest_3()
        {
            var solution = new _0937_ReorderDataInLogFiles();
            var result   = solution.ReorderLogFiles(new string[] { "l5sh 6 3869 08 1295", "16o 94884717383724 9", "43 490972281212 3 51", "9 ehyjki ngcoobi mi", "2epy 85881033085988", "7z fqkbxxqfks f y dg", "9h4p 5 791738 954209", "p i hz uubk id s m l", "wd lfqgmu pvklkdp u", "m4jl 225084707500464", "6np2 bqrrqt q vtap h", "e mpgfn bfkylg zewmg", "ttzoz 035658365825 9", "k5pkn 88312912782538", "ry9 8231674347096 00", "w 831 74626 07 353 9", "bxao armngjllmvqwn q", "0uoj 9 8896814034171", "0 81650258784962331", "t3df gjjn nxbrryos b" });

            AssertHelper.AssertArray(new string[] { "bxao armngjllmvqwn q", "6np2 bqrrqt q vtap h", "9 ehyjki ngcoobi mi", "7z fqkbxxqfks f y dg", "t3df gjjn nxbrryos b", "p i hz uubk id s m l", "wd lfqgmu pvklkdp u", "e mpgfn bfkylg zewmg", "l5sh 6 3869 08 1295", "16o 94884717383724 9", "43 490972281212 3 51", "2epy 85881033085988", "9h4p 5 791738 954209", "m4jl 225084707500464", "ttzoz 035658365825 9", "k5pkn 88312912782538", "ry9 8231674347096 00", "w 831 74626 07 353 9", "0uoj 9 8896814034171", "0 81650258784962331" }, result);
        }
示例#6
0
        public void Shuffle_3()
        {
            var solution = new _1470_ShuffleTheArray();
            var result   = solution.Shuffle(new int[] { 1, 1, 2, 2 }, 2);

            AssertHelper.AssertArray(new int[] { 1, 2, 1, 2 }, result);
        }
        public void ArrayRankTransform_2()
        {
            var solution = new _1331_RankTransformOfAnArray();
            var result   = solution.ArrayRankTransform(new int[] { 100, 100, 100 });

            AssertHelper.AssertArray(new int[] { 1, 1, 1 }, result);
        }
        public void RelativeSortArray_1()
        {
            var solution = new _1122_RelativeSortArray();
            var result   = solution.RelativeSortArray(new int[] { 2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19 }, new int[] { 2, 1, 4, 3, 9, 6 });

            AssertHelper.AssertArray(new int[] { 2, 2, 2, 1, 4, 3, 3, 9, 6, 7, 19 }, result);
        }
示例#9
0
        public void SortedSquares_2()
        {
            var solution = new _0977_SquaresOfASortedArray();
            var result   = solution.SortedSquares(new int[] { -7, -3, 2, 3, 11 });

            AssertHelper.AssertArray(new int[] { 4, 9, 9, 49, 121 }, result);
        }
        public void DistributeCandies_2()
        {
            var solution = new _1103_DistributeCandiesToPeople();
            var result   = solution.DistributeCandies(10, 3);

            AssertHelper.AssertArray(new int[] { 5, 2, 3 }, result);
        }
        public void DistributeCandies_1()
        {
            var solution = new _1103_DistributeCandiesToPeople();
            var result   = solution.DistributeCandies(7, 4);

            AssertHelper.AssertArray(new int[] { 1, 2, 3, 1 }, result);
        }
示例#12
0
        public void SmallerNumbersThanCurrent_1()
        {
            var solution = new _1365_HowManyNumbersAreSmallerThanTheCurrentNumber();
            var result   = solution.SmallerNumbersThanCurrent(new int[] { 8, 1, 2, 2, 3 });

            AssertHelper.AssertArray(new int[] { 4, 0, 1, 1, 3 }, result);
        }
示例#13
0
        public void SmallerNumbersThanCurrent_3()
        {
            var solution = new _1365_HowManyNumbersAreSmallerThanTheCurrentNumber();
            var result   = solution.SmallerNumbersThanCurrent(new int[] { 7, 7, 7, 7 });

            AssertHelper.AssertArray(new int[] { 0, 0, 0, 0 }, result);
        }
示例#14
0
        public void NextGreaterElements_1()
        {
            var solution = new _0503_NextGreaterElementII();
            var result   = solution.NextGreaterElements(new int[] { 1, 2, 1 });

            AssertHelper.AssertArray(new int[] { 2, -1, 2 }, result);
        }
示例#15
0
        public void Expand_1()
        {
            var solution = new _1087_BraceExpansion();
            var result   = solution.Expand("{a,b}c{d,e}f");

            AssertHelper.AssertArray(new string[] { "acdf", "acef", "bcdf", "bcef" }, result);
        }
示例#16
0
        public void SortedSquares_1()
        {
            var solution = new _0977_SquaresOfASortedArray();
            var result   = solution.SortedSquares(new int[] { -4, -1, 0, 3, 10 });

            AssertHelper.AssertArray(new int[] { 0, 1, 9, 16, 100 }, result);
        }
示例#17
0
        public void Shuffle_2()
        {
            var solution = new _1470_ShuffleTheArray();
            var result   = solution.Shuffle(new int[] { 1, 2, 3, 4, 4, 3, 2, 1 }, 4);

            AssertHelper.AssertArray(new int[] { 1, 4, 2, 3, 3, 2, 4, 1 }, result);
        }
示例#18
0
        public void HighFive_1()
        {
            var solution = new _1086_HighFive();
            var result   = solution.HighFive(new int[][]
            {
                new int[] { 1, 91 },
                new int[] { 1, 92 },
                new int[] { 2, 93 },
                new int[] { 2, 97 },
                new int[] { 1, 60 },
                new int[] { 2, 77 },
                new int[] { 1, 65 },
                new int[] { 1, 87 },
                new int[] { 1, 100 },
                new int[] { 2, 100 },
                new int[] { 2, 76 },
            });

            AssertHelper.AssertArray(
                new int[][]
            {
                new int[] { 1, 87 },
                new int[] { 2, 88 },
            }, result);
        }
示例#19
0
        public void Shuffle_1()
        {
            var solution = new _1470_ShuffleTheArray();
            var result   = solution.Shuffle(new int[] { 2, 5, 1, 3, 4, 7 }, 3);

            AssertHelper.AssertArray(new int[] { 2, 3, 5, 4, 1, 7 }, result);
        }
        public void SortArrayByParityII_1()
        {
            var solution = new _0922_SortArrayByParityII();
            var result   = solution.SortArrayByParityII(new int[] { 4, 2, 5, 7 });

            AssertHelper.AssertArray(new int[] { 4, 5, 2, 7 }, result);
        }
        public void ArrayRankTransform_3()
        {
            var solution = new _1331_RankTransformOfAnArray();
            var result   = solution.ArrayRankTransform(new int[] { 37, 12, 28, 9, 100, 56, 80, 5, 12 });

            AssertHelper.AssertArray(new int[] { 5, 3, 4, 2, 8, 6, 7, 1, 3 }, result);
        }
示例#22
0
        public void DeckRevealedIncreasing_1()
        {
            var solution = new _0950_RevealCardsInIncreasingOrder();
            var result   = solution.DeckRevealedIncreasing(new int[] { 17, 13, 11, 2, 3, 5, 7 });

            AssertHelper.AssertArray(new int[] { 2, 13, 3, 11, 5, 17, 7 }, result);
        }
        public void ReorderLogFilesTest_2()
        {
            var solution = new _0937_ReorderDataInLogFiles();
            var result   = solution.ReorderLogFiles(new string[] { "6p tzwmh ige mc", "ns 566543603829", "ubd cujg j d yf", "ha6 1 938 376 5", "3yx 97 666 56 5", "d 84 34353 2249", "0 tllgmf qp znc", "s 1088746413789", "ys0 splqqxoflgx", "uhb rfrwt qzx r", "u lrvmdt ykmox", "ah4 4209164350", "rap 7729 8 125", "4 nivgc qo z i", "apx 814023338 8" });

            AssertHelper.AssertArray(new string[] { "ubd cujg j d yf", "u lrvmdt ykmox", "4 nivgc qo z i", "uhb rfrwt qzx r", "ys0 splqqxoflgx", "0 tllgmf qp znc", "6p tzwmh ige mc", "ns 566543603829", "ha6 1 938 376 5", "3yx 97 666 56 5", "d 84 34353 2249", "s 1088746413789", "ah4 4209164350", "rap 7729 8 125", "apx 814023338 8" }, result);
        }
        public void FindWords_1()
        {
            var solution = new _0500_KeyboardRow();
            var result   = solution.FindWords(new string[] { "Hello", "Alaska", "Dad", "Peace" });

            AssertHelper.AssertArray(new string[] { "Alaska", "Dad" }, result);
        }
        public void ReorderLogFilesTest()
        {
            var solution = new _0937_ReorderDataInLogFiles();
            var result   = solution.ReorderLogFiles(new string[] { "dig1 8 1 5 1", "let1 art can", "dig2 3 6", "let2 own kit dig", "let3 art zero" });

            AssertHelper.AssertArray(new string[] { "let1 art can", "let3 art zero", "let2 own kit dig", "dig1 8 1 5 1", "dig2 3 6" }, result);
        }
示例#26
0
        public void Expand_2()
        {
            var solution = new _1087_BraceExpansion();
            var result   = solution.Expand("abcd");

            AssertHelper.AssertArray(new string[] { "abcd" }, result);
        }
示例#27
0
        public void FairCandySwap_1()
        {
            var solution = new _0888_FairCandySwap();
            var result   = solution.FairCandySwap(new int[] { 1, 1 }, new int[] { 2, 2 });

            AssertHelper.AssertArray(new int[] { 1, 2 }, result);
        }
示例#28
0
        public void Expand_3()
        {
            var solution = new _1087_BraceExpansion();
            var result   = solution.Expand("{a,b}{z,x,y}");

            AssertHelper.AssertArray(new string[] { "ax", "ay", "az", "bx", "by", "bz" }, result);
        }
        public void UncommonFromSentences_1()
        {
            var solution = new _0884_UncommonWordsFromTwoSentences();
            var result   = solution.UncommonFromSentences("this apple is sweet", "this apple is sour");

            AssertHelper.AssertArray(new string[] { "sweet", "sour" }, result);
        }
示例#30
0
        public void SortByBits_5()
        {
            var solution = new _1356_SortIntegersByTheNumberOf1Bits();
            var result   = solution.SortByBits(new int[] { 10, 100, 1000, 10000 });

            AssertHelper.AssertArray(new int[] { 10, 100, 10000, 1000 }, result);
        }