Beispiel #1
0
        public void TwoSumWithSameKey()
        {
            var intArr = new List <int> {
                2, 2, 11, 15
            };
            var target = 9;
            var twoSum = new CustomTwoSum();
            var result = twoSum.TwoSum(intArr, target);

            Assert.IsNotNull(result);
        }
Beispiel #2
0
        public void TwoSumTest()
        {
            var intArr = new List <int> {
                2, 7, 11, 15
            };
            var target = 9;
            var twoSum = new CustomTwoSum();
            var result = twoSum.TwoSum(intArr, target);

            Assert.IsTrue(result.Contains(0));
            Assert.IsTrue(result.Contains(1));
            Assert.IsTrue(result.Aggregate((x, y) => intArr[x] + intArr[y]) == target);
        }