コード例 #1
0
        public void Example0_3()
        {
            var sol = new CombinationSumIII();

            var expected = new IList <int> [0];

            var output = sol
                         .CombinationSum3(k: 3, n: 5)
                         .Select(o => string.Join(", ", o))
                         .ToList();

            CollectionAssert.AreEquivalent(expected, output);
        }
コード例 #2
0
        public void Example1()
        {
            var sol = new CombinationSumIII();

            var expected = new[]
            {
                "1, 2, 4"
            };

            var output = sol
                         .CombinationSum3(k: 3, n: 7)
                         .Select(o => string.Join(", ", o))
                         .ToList();

            CollectionAssert.AreEquivalent(expected, output);
        }
コード例 #3
0
        public void Example3()
        {
            var sol = new CombinationSumIII();

            var expected = new[]
            {
                "1, 5, 9",
                "1, 6, 8",
                "2, 4, 9",
                "2, 5, 8",
                "2, 6, 7",
                "3, 4, 8",
                "3, 5, 7",
                "4, 5, 6"
            };

            var output = sol
                         .CombinationSum3(k: 3, n: 15)
                         .Select(o => string.Join(", ", o))
                         .ToList();;

            CollectionAssert.AreEquivalent(expected, output);
        }