예제 #1
0
        public void FindMedianSortedArrays_Even_Test()
        {
            var nums1 = new[] { 1, 3 };
            var nums2 = new[] { 2 };

            double ret = FindMedianSortedArrays.FindMedianSortedArraysFunc(nums1, nums2);

            Assert.AreEqual((double)2, ret);
        }
예제 #2
0
        public void FindMedianSortedArrays_Odd_Sort_Test()
        {
            var nums1 = new[] { 1, 2 };
            var nums2 = new[] { 3, 4 };

            double ret = FindMedianSortedArrays.FindMedianSortedArraysFunc(nums1, nums2);

            Assert.AreEqual((double)2.5, ret);
        }
예제 #3
0
        public void TestFindMedianSortedArraysRecursive()
        {
            var arr1 = new int[] { 1, 21, 31, 41 };
            var arr2 = new int[] { 2, 4, 50 };

            var r = FindMedianSortedArrays.FindKthIn2SortedArraies(arr1, 0, arr2, 0, 3);

            Assert.AreEqual(r, 4);

            var arr3 = new int[] { 1, 21, 31, 41 };
            var arr4 = new int[] { 2, 4, 50, 100 };

            r = FindMedianSortedArrays.FindKthIn2SortedArraies(arr3, 0, arr4, 0, 5);
            Assert.AreEqual(r, 31);
        }
예제 #4
0
        public void TestFindMedianSortedArrays()
        {
            var arr1 = new int[] { 1, 21, 31, 41 };
            var arr2 = new int[] { 2, 4, 50 };

            var r = FindMedianSortedArrays.FindMedianSortedArrays1(arr1, arr2);

            Assert.AreEqual(r, 21);

            var arr3 = new int[] { 1, 21, 31, 41 };
            var arr4 = new int[] { 2, 4, 50, 100 };

            r = FindMedianSortedArrays.FindMedianSortedArrays1(arr3, arr4);
            Assert.AreEqual(r, 26);
        }
예제 #5
0
        public void Debug()
        {
            ISolution solution = new FindMedianSortedArrays();

            solution.Test();
        }
예제 #6
0
 public void Test(int[] arr1, int[] arr2, double result)
 {
     Assert.Equal(FindMedianSortedArrays.Run(arr1, arr2), result);
 }