Java solution | Binary Search | TC = O(nlogm)
\n// Tc = O(nlogm)   => dependent on count function\n\nclass Solution {\n    public long kthSmallestProduct(int[] nums1, int[] nums2, long k) {\n        long lo
```\n// Tc = O(nlogm)   => dependent on count function\n\nclass Solution {\n    public long kthSmallestProduct(int[] nums1, int[] nums2, long k) {\n        long low = (long)-1e10, high = (long)1e10;\n        \n        while(low <= high){\n            long dotProduct = (low+high)/2;\n            if(countNoOfElements(nums1, nums2, dotProduct) < k) \n                low = dotProduct+1;\n            else\n                high = dotProduct-1;\n        }\n        return high;\n    }\n    \n    private long countNoOfElements(int[] nums1, int[] nums2, long dotProduct){  // this function will return the no. of elements(after product) which are less than dotProduct\n        long count = 0;\n        for(int element : nums1){\n            if(element >= 0){     // if positve\n                int low = 0, high = nums2.length;  // binary search on nums2\n                while(low < high){\n                    int mid = (low+high)/2;\n                    if((long)element * nums2[mid] < dotProduct)\n                        low = mid+1;\n                    else\n                        high = mid;\n                }\n               count += low;    // no. of elemets after product with element smaller than dotproduct\n            }\n            else{          //if negative  => binary search in some reverse order\n                int low = 0, high = nums2.length;\n                while(low < high){\n                    int mid = (low+high)/2;\n                    if((long) element * nums2[mid] >= dotProduct)\n                        low = mid+1;\n                    else\n                        high = mid;\n                }\n                \n                count += nums2.length - low;   // in negative element case smaller element will be on right side\n            }\n            \n        }\n        return count;\n    }\n}\n```
['Binary Tree', 'Java']