text: import unittest
  from typing import List
  
  import utils
  
  
  class Solution:
      def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
          m = len(nums1)
          n = len(nums2)
          if m > n:
              nums1, nums2 = nums2, nums1
              m, n = n, m
  
          lo = 0
          hi = m
          half = (m + n + 1) >> 1
  
          while True:
              i = lo + ((hi - lo) >> 1)
              j = half - i
  
              if i > 0 and nums1[i - 1] > nums2[j]:
                  hi = i - 1
              elif i < m and nums2[j - 1] > nums1[i]:
                  lo = i + 1
              else:
                  if i == 0:
                      max_of_left = nums2[j - 1]
                  elif j == 0:
                      max_of_left = nums1[i - 1]
                  else:
                      max_of_left = max(nums1[i - 1], nums2[j - 1])
  
                  if (m + n) & 1 == 1:
                      return max_of_left
  
                  if i == m:
                      min_of_right = nums2[j]
                  elif j == n:
                      min_of_right = nums1[i]
                  else:
                      min_of_right = min(nums1[i], nums2[j])
  
                  return (max_of_left + min_of_right) / 2
  
  
  class Test(unittest.TestCase):
      def test(self):
          utils.test(self, __file__, Solution)
  
  
  if __name__ == '__main__':
      unittest.main()
  