[Java] Binary Search on the Answer
Binary search on the answer and use a helper function to count the number of products that are less than mid.\nSimilar problem from AtCoder - https://atcoder.jp
Binary search on the answer and use a helper function to count the number of products that are less than mid.\nSimilar problem from AtCoder - https://atcoder.jp/contests/abc155/tasks/abc155_d\n\n```\n    public long kthSmallestProduct(int[] nums1, int[] nums2, long k) {\n        long lo = (long) -1e10;\n        long hi = (long) 1e10;\n        while (lo < hi) {\n            final long mid = lo + hi + 1 >> 1;\n            if (f(nums1, nums2, mid) < k) {\n                lo = mid;\n            } else {\n                hi = mid - 1;\n            }\n        }\n        return lo;\n    }\n\n    private static long f(int[] nums1, int[] nums2, long mid) {\n        long count = 0;\n        for (int num : nums1) {\n            int lo = 0;\n            int hi = nums2.length;\n            if (num < 0) {\n                while (lo < hi) {\n                    final int m = lo + hi >>> 1;\n                    if ((long) nums2[m] * num >= mid) {\n                        lo = m + 1;\n                    } else {\n                        hi = m;\n                    }\n                }\n                count += nums2.length - lo;\n            } else {\n                while (lo < hi) {\n                    final int m = lo + hi >>> 1;\n                    if ((long) nums2[m] * num < mid) {\n                        lo = m + 1;\n                    } else {\n                        hi = m;\n                    }\n                }\n                count += lo;\n            }\n        }\n        return count;\n    }\n```
[]