本文整理汇总了Python中solution.Solution.findMedianSortedArrays方法的典型用法代码示例。如果您正苦于以下问题:Python Solution.findMedianSortedArrays方法的具体用法?Python Solution.findMedianSortedArrays怎么用?Python Solution.findMedianSortedArrays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solution.Solution
的用法示例。
在下文中一共展示了Solution.findMedianSortedArrays方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestCase
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import findMedianSortedArrays [as 别名]
class TestCase(unittest.TestCase):
def setUp(self):
self.solution = Solution()
def testSolution01(self):
a = (1, 3, 5, 7, 9, 11)
b = (2, 4, 6, 8, 10)
self.assertEqual(self.solution.findMedianSortedArrays(a, b), 6)
def testSolution02(self):
a = (1, 3, 4, 5, 7, 9)
b = (2, 6, 8, 10)
self.assertEqual(self.solution.findMedianSortedArrays(a, b), 5.5)
def testSolution03(self):
a = (1, 2, 3, 4, 5, 9)
b = (6, 7, 8, 10, 11)
self.assertEqual(self.solution.findMedianSortedArrays(a, b), 6)
def testSolution04(self):
a = (1, 2, 3, 4, 5, 6)
b = (7, 8, 9, 10, 11)
self.assertEqual(self.solution.findMedianSortedArrays(a, b), 6)
def testSolution05(self):
a = (1, 4, 8, 9, 10, 11)
b = (2, 3, 5, 6, 7)
self.assertEqual(self.solution.findMedianSortedArrays(a, b), 6)
示例2: main
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import findMedianSortedArrays [as 别名]
def main():
nums = []
solution = Solution()
for line in stdin:
nums.append(line.strip())
if len(nums) == 2:
nums1 = [int(x) for x in nums.pop(0).split(" ") if x != ""]
nums2 = [int(x) for x in nums.pop(0).split(" ") if x != ""]
print solution.findMedianSortedArrays(nums1, nums2)
示例3: test_8
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import findMedianSortedArrays [as 别名]
def test_8():
sol = Solution()
nums1 = [10, 20, 30, 50, 60, 70, 80]
nums2 = [9, 11, 23, 35, 43, 49, 51, 63]
assert sol.findMedianSortedArrays(nums1, nums2) == median(nums1, nums2)
assert sol.findMedianSortedArrays(nums2, nums1) == median(nums1, nums2)
示例4: test_7
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import findMedianSortedArrays [as 别名]
def test_7():
sol = Solution()
nums1 = [1]
nums2 = [2, 3, 4, 5, 6, 7]
assert sol.findMedianSortedArrays(nums1, nums2) == median(nums1, nums2)
assert sol.findMedianSortedArrays(nums2, nums1) == median(nums1, nums2)
示例5: test_6
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import findMedianSortedArrays [as 别名]
def test_6():
sol = Solution()
nums1 = range(0, 10)
nums2 = range(200, 300)
assert sol.findMedianSortedArrays(nums1, nums2) == median(nums1, nums2)
assert sol.findMedianSortedArrays(nums2, nums1) == median(nums1, nums2)
示例6: test_5
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import findMedianSortedArrays [as 别名]
def test_5():
sol = Solution()
nums1 = []
nums2 = sorted(np.random.choice(1000, 800, replace=True).tolist())
assert sol.findMedianSortedArrays(nums1, nums2) == median(nums1, nums2)
assert sol.findMedianSortedArrays(nums2, nums1) == median(nums1, nums2)
示例7: test_0
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import findMedianSortedArrays [as 别名]
def test_0():
sol = Solution()
nums1 = []
nums2 = []
assert sol.findMedianSortedArrays(nums1, nums2) == median(nums1, nums2)
assert sol.findMedianSortedArrays(nums2, nums1) == median(nums1, nums2)
示例8: Solution
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import findMedianSortedArrays [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from solution import Solution
nums1 = [1]
nums2 = [2]
sol = Solution()
result = sol.findMedianSortedArrays(nums1, nums2)
print(result)