Swift Binary Search
Thank you to Ankush093 for their solution in C++ here\n\n\nclass Solution {\n    func kthSmallestProduct(_ nums1: [Int], _ nums2: [Int], _ k: Int) -> Int {\n   
Thank you to Ankush093 for their solution in C++ [here](https://leetcode.com/problems/kth-smallest-product-of-two-sorted-arrays/discuss/1753363/Binary-search)\n\n```\nclass Solution {\n    func kthSmallestProduct(_ nums1: [Int], _ nums2: [Int], _ k: Int) -> Int {\n        var nums1 = nums1\n        var nums2 = nums2\n        \n        var n = nums1.count\n        var m = nums2.count\n        var result = 0\n        var minIndex = min(nums1[0], nums2[0])\n        var maxIndex = max(nums1[n - 1], nums2[m - 1])\n        \n        var left = min(minIndex, maxIndex*minIndex)\n        var right = max(maxIndex*maxIndex, minIndex*minIndex)\n        \n        while left <= right {\n            var mid = left + (right - left) / 2\n            if valid(&nums1,&nums2,n,m,mid,k) {\n                result = mid\n                right = mid - 1\n            } else {\n                left = mid + 1\n            }\n        }\n        \n        return result\n    }\n    \n    func getValue1(_ x: Int, _ nums2: inout [Int], _ m: Int, _ val: Int) -> Int {\n        var left = 0\n        var right = m - 1\n        var result = m\n        \n        while left <= right {\n            var mid = left + (right - left) / 2\n            if x * nums2[mid] <= val {\n                result = mid\n                right = mid - 1\n            } else {\n                left = mid + 1\n            }\n        }\n        return m - result\n    }\n    \n    func getValue2(_ x: Int, _ nums2: inout [Int], _ m: Int, _ val: Int) -> Int {\n        var left = 0\n        var right = m - 1\n        var result = 0\n        \n        while left <= right {\n            var mid = left + (right - left) / 2\n            if x * nums2[mid] <= val {\n                result = mid + 1\n                left = mid + 1\n            } else {\n                right = mid - 1\n            }\n        }\n        return result\n    }\n    \n    func valid(_ nums1: inout [Int], _ nums2: inout [Int], _ n : Int, _ m: Int, _ mid: Int, _ k : Int) -> Bool {\n        var result = 0\n        for index in 0 ..< n {\n            if nums1[index] < 0 {\n                result += getValue1(nums1[index], &nums2, m, mid)\n            } else {\n                result += getValue2(nums1[index], &nums2, m, mid)\n            }\n        }\n        return result >= k\n    }\n}\n```
['Binary Search', 'Swift']