java solution with detailed explaination
class Solution {\n    public int findMaxNegativeIndex(int[] nums)\n    {\n        var low = 0;//negtive no\n        var high = nums.length -1;//not a negative n
class Solution {\n    public int findMaxNegativeIndex(int[] nums)\n    {\n        var low = 0;//negtive no\n        var high = nums.length -1;//not a negative no\n        if(nums[low] > 0) return -1;//don\'t not have any negative value\n        if(nums[high] < 0) return high;//all numbers are negative\n        while(low < high)\n        {\n            var m = (low + high + 1)/2;\n            if(nums[m] < 0)\n            {\n                low = m;\n            }else{\n                if(high == m) break;\n                high = m;\n            }\n        }\n        return low;\n    }\n    public long kthSmallestProduct(int[] nums1, int[] nums2, long k) {\n        long low = Long.MIN_VALUE/2;//have less than k no product than this\n        long high = Long.MAX_VALUE/2;//have atleast k no product less than this\n        var negInd1 = findMaxNegativeIndex(nums1);\n        var negInd2 = findMaxNegativeIndex(nums2);\n        while(low < high)\n        {\n            long m = low + (high-low)/2;\n            var val = getNoOfProductLessThan(m, nums1, nums2, negInd1, negInd2);\n            if(k <= val){\n                high = m;\n            }else{\n                 if(low == m) break;\n                low = m;\n            }\n        }\n\n        return high;\n    }\n    public long getNoOfProductLessThan(long m, int[] nums1, int[] nums2, int f, int s)\n    {\n        var l1 = nums1.length;\n        var l2 = nums2.length;\n        \n        long ans = 0;\n\n        //when nums1 pos and nums2 is pos\n        var j = l2-1;\n        for(int i = f+1; i < l1; i++)\n        {\n            //special case when nums1[i] == 0\n            if(nums1[i] == 0)\n            {\n                if(m >= 0) ans+= l2;\n                continue;\n            }\n            while(j > s && ( (long)nums1[i] * (long)nums2[j] > m)  )\n            {\n                j--;\n            }\n            if(j > s) ans+= j-s;\n        }\n\n        //when nums1 pos and nums2 is neg\n        j = s;\n        for(int i = l1-1; i > f; i--)\n        {\n            if(nums1[i] == 0) break;\n            while(j >= 0 && ( (long)nums1[i] * (long)nums2[j] > m)  )\n            {\n                j--;\n            }\n            if(j >= 0) ans += (j+1);\n        }\n\n        //when nums1 neg and nums2 is neg\n        j = 0;\n        for(int i = f; i >= 0; i--)\n        {\n            while(j <= s && ( (long)nums1[i] * (long)nums2[j] > m)  )\n            {\n                j++;\n            }\n            if(j <= s) ans+= (s-j+1);\n        }\n\n        //when nums1 neg and nums2 is pos\n        j = s+1;\n        for(int i = 0; i <= f; i++)\n        {\n            while(j < l2 && ( (long)nums1[i] * (long)nums2[j] > m)  )\n            {\n                j++;\n            }\n            if(j < l2) ans += (l2 - j);\n        }\n        return ans;\n    }\n}
[]