static void Main(string[] args) { ArrayPairSum problem1 = new ArrayPairSum(); int[] nums = { 2, 1, 4, 5, 1, 4, 1, 3, 5, 2 }; problem1.ArrayPairSumFunction(nums); // works but need to add exception if array has an odd number of elements }
public static void testOutputPairsLinearTime() { var watch = System.Diagnostics.Stopwatch.StartNew(); ArrayPairSum a = new ArrayPairSum(100000000); for (int i = 0; i < 100000000; i++) { a.arr[i] = i + 2; } //lets say k == 12 a.PairSumLinearTime(12); Console.WriteLine($"Execution Time (O(Logn): {watch.ElapsedMilliseconds} ms"); }
public void OutputQuantityOfUniquePairsThatEqualK(int[] arr, int k, int count) { var result = ArrayPairSum.PairSum(arr, k); Assert.True(result.Count == count, $"Count of unique pairs summing to {k} is not {count}"); }
public static void Run() { ArrayPairSum.FindPairs(new int[] { 1, 1, 2, 3, 4 }, 4); }