コード例 #1
0
    def test_findMedianSortedArrays_odd(self):
        nums1 = [1, 2]
        nums2 = [3, 4, 5]

        solution = Solution()
        result = solution.findMedianSortedArrays(nums1, nums2)

        self.assertEqual(3, result)
コード例 #2
0
    def test_findMedianSortedArraysTest_nums2SingleItem_odd(self):
        nums1 = [2, 3, 4, 5, 6, 7]
        nums2 = [1]

        solution = Solution()
        result = solution.findMedianSortedArrays(nums1, nums2)

        self.assertEqual(4, result)
コード例 #3
0
    def test_findMedianSortedArraysTest_num2Empty_nums1SingleItem(self):
        nums1 = [1]
        nums2 = []

        solution = Solution()
        result = solution.findMedianSortedArrays(nums1, nums2)

        self.assertEqual(1, result)
コード例 #4
0
    def test_findMedianSortedArraysTest_nums1SingleItem_even(self):
        nums1 = [1]
        nums2 = [2, 3, 4, 5, 6]

        solution = Solution()
        result = solution.findMedianSortedArrays(nums1, nums2)

        self.assertEqual(3.5, result)
コード例 #5
0
    def test_findMedianSortedArraysTest_num2Empty(self):
        nums1 = [1, 2, 3]
        nums2 = []

        solution = Solution()
        result = solution.findMedianSortedArrays(nums1, nums2)

        self.assertEqual(2, result)
コード例 #6
0
    def test_findMedianSortedArraysTest_even(self):
        nums1 = [1, 2, 3, 4]
        nums2 = [5, 6, 7, 8]

        solution = Solution()
        result = solution.findMedianSortedArrays(nums1, nums2)

        self.assertEqual(4.5, result)
コード例 #7
0
    def test_findMedianSortedArraysTest_duplicateItems(self):
        nums1 = [1, 1, 3, 3]
        nums2 = [1, 1, 3, 3]

        solution = Solution()
        result = solution.findMedianSortedArrays(nums1, nums2)

        self.assertEqual(2, result)
コード例 #8
0
    def test_findMedianSortedArraysTest_mixedArray(self):
        nums1 = [2]
        nums2 = [1, 3, 4]

        solution = Solution()
        result = solution.findMedianSortedArrays(nums1, nums2)

        self.assertEqual(2.5, result)
コード例 #9
0
    def test_findMedianSortedArrays(self):
        nums1 = [
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
            20, 21, 22
        ]
        nums2 = [0, 6]

        solution = Solution()
        result = solution.findMedianSortedArrays(nums1, nums2)

        self.assertEqual(10.5, result)