public void FourSumTest_SomeDuplicate() { int[] input = { 1, 0, 0, 1, 0, 0, -1, -1, 0, 0 }; var solution = new _018_4Sum(); var result = solution.FourSum(input, 0); Assert.AreEqual(3, result.Count); AssertHelper.AssertList(new List <IList <int> > { new List <int> { -1, -1, 1, 1 }, new List <int> { -1, 0, 0, 1 }, new List <int> { 0, 0, 0, 0 } }, result); result = solution.FourSum(input, 1); Assert.AreEqual(2, result.Count); AssertHelper.AssertList(new List <IList <int> > { new List <int> { -1, 0, 1, 1 }, new List <int> { 0, 0, 0, 1 } }, result); }
public void FourSumTest_Empty() { int[] input = { }; var solution = new _018_4Sum(); var result = solution.FourSum(input, 0); Assert.AreEqual(0, result.Count); }
public void FourSumTest_2() { int[] input = { 1, 4, -3, 0, 0, 0, 5, 0 }; var solution = new _018_4Sum(); var result = solution.FourSum(input, 0); Assert.AreEqual(1, result.Count); AssertHelper.AssertList(new List<IList<int>> { new List<int> { 0, 0, 0, 0 } }, result); }
public void FourSumTest() { int[] input = { 1, 0, -1, 0, -2, 2 }; var solution = new _018_4Sum(); var result = solution.FourSum(input, 0); Assert.AreEqual(3, result.Count); AssertHelper.AssertList(new List<IList<int>> { new List<int> { -2, -1, 1, 2 }, new List<int> { -2, 0, 0, 2 }, new List<int> { -1, 0, 0, 1 } }, result); }
public void FourSumTest_2() { int[] input = { 1, 4, -3, 0, 0, 0, 5, 0 }; var solution = new _018_4Sum(); var result = solution.FourSum(input, 0); Assert.AreEqual(1, result.Count); AssertHelper.AssertList(new List <IList <int> > { new List <int> { 0, 0, 0, 0 } }, result); }
public void FourSumTest_NotEnough() { var solution = new _018_4Sum(); int[] input1 = { -1 }; var result = solution.FourSum(input1, 0); Assert.AreEqual(0, result.Count); int[] input2 = { -1, 0 }; result = solution.FourSum(input2, 0); Assert.AreEqual(0, result.Count); int[] input3 = { -1, 0, 1 }; result = solution.FourSum(input3, 0); Assert.AreEqual(0, result.Count); }
public void FourSumTest() { int[] input = { 1, 0, -1, 0, -2, 2 }; var solution = new _018_4Sum(); var result = solution.FourSum(input, 0); Assert.AreEqual(3, result.Count); AssertHelper.AssertList(new List <IList <int> > { new List <int> { -2, -1, 1, 2 }, new List <int> { -2, 0, 0, 2 }, new List <int> { -1, 0, 0, 1 } }, result); }
public void FourSumTest_SomeDuplicate() { int[] input = { 1, 0, 0, 1, 0, 0, -1, -1, 0, 0 }; var solution = new _018_4Sum(); var result = solution.FourSum(input, 0); Assert.AreEqual(3, result.Count); AssertHelper.AssertList(new List<IList<int>> { new List<int> { -1, -1, 1, 1 }, new List<int> { -1, 0, 0, 1 }, new List<int> { 0, 0, 0, 0 } }, result); result = solution.FourSum(input, 1); Assert.AreEqual(2, result.Count); AssertHelper.AssertList(new List<IList<int>> { new List<int> { -1, 0, 1, 1 }, new List<int> { 0, 0, 0, 1 } }, result); }