[Python3] binary search
\n\nclass Solution:\n    def kthSmallestProduct(self, nums1: List[int], nums2: List[int], k: int) -> int:\n        \n        def fn(val):\n            """Return
\n```\nclass Solution:\n    def kthSmallestProduct(self, nums1: List[int], nums2: List[int], k: int) -> int:\n        \n        def fn(val):\n            """Return count of products <= val."""\n            ans = 0\n            for x in nums1: \n                if x < 0: ans += len(nums2) - bisect_left(nums2, ceil(val/x))\n                elif x == 0: \n                    if 0 <= val: ans += len(nums2)\n                else: ans += bisect_right(nums2, floor(val/x))\n            return ans \n            \n        lo, hi = -10**10, 10**10 + 1\n        while lo < hi: \n            mid = lo + hi >> 1\n            if fn(mid) < k: lo = mid + 1\n            else: hi = mid\n        return lo \n```\n\n```\nclass Solution:\n    def kthSmallestProduct(self, nums1: List[int], nums2: List[int], k: int) -> int:\n        neg = [x for x in nums1 if x < 0]\n        pos = [x for x in nums1 if x >= 0]\n        \n        def fn(val):\n            """Return count of products <= val."""\n            ans = 0\n            lo, hi = 0, len(nums2)-1\n            for x in neg[::-1] + pos if val >= 0 else neg + pos[::-1]: \n                if x < 0: \n                    while lo < len(nums2) and x*nums2[lo] > val: lo += 1\n                    ans += len(nums2) - lo\n                elif x == 0: \n                    if 0 <= val: ans += len(nums2)\n                else: \n                    while 0 <= hi and x*nums2[hi] > val: hi -= 1\n                    ans += hi+1\n            return ans \n        \n        lo, hi = -10**10, 10**10 + 1\n        while lo < hi: \n            mid = lo + hi >> 1\n            if fn(mid) < k: lo = mid + 1\n            else: hi = mid\n        return lo \n```
['Python3']