Exemplo n.º 1
0
        public void FindTargetSumWaysTests()
        {
            TargetSum obj = new TargetSum();

            var str = new int[] { 1, 1, 1, 1, 1 };
            var x   = obj.FindTargetSumWays(str, 3);//5

            str = new int[] { 1, 1, 1, 1, 1, 1 };
            x   = obj.FindTargetSumWays(str, 4);//6
        }
Exemplo n.º 2
0
        public void TestMethod1(int[] nums, int S, int expected)
        {
            // Arrange
            TargetSum question = new TargetSum();

            // Act
            int actual = question.FindTargetSumWays(nums, S);

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
 public void TwoIntegersSumToTarget_2IntsInPassedArraySumToTarget_ReturnsTrue()
 {
     int[] input = new int[] { 1, 2, 3, 4 };
     Assert.AreEqual(true, TargetSum.TwoIntegersSumToTarget(input, 5));
 }
Exemplo n.º 4
0
 public void TwoIntegersSumToTarget_EmptyArrayPassed_ReturnsFalse()
 {
     int[] input = new int[] { };
     Assert.AreEqual(false, TargetSum.TwoIntegersSumToTarget(input, 5));
 }
Exemplo n.º 5
0
 public void TwoIntegersSumToTarget_2IntsInPassedArrayDoNotSumToTarget_ReturnsFalse()
 {
     int[] input = new int[] { 1, 2, 3, 4 };
     Assert.AreEqual(false, TargetSum.TwoIntegersSumToTarget(input, 20));
 }
Exemplo n.º 6
0
        public void Given_array_When_find_Then_return()
        {
            var nums = new int[] { 1, 1, 1, 1, 1 };

            Assert.AreEqual(5, TargetSum.FindTargetSumWays(nums, 3));
        }