C++ O(NLogN) Binary Search + Sliding Window solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    long long getPairsCount(vector<long long>& b, vector<long long>& d, long long prod){\n        long long count = 0;\n        int index1, index2;\n\n        if(b.empty() || d.empty()){\n            return 0;\n        }\n\n        index1 = 0;\n        index2 = d.size() - 1;\n        while(index1 < b.size()){\n            while(index2 >= 0 && (b[index1] * d[index2] > prod)){\n                index2--;\n            }\n            count += index2 + 1;\n            index1++;\n        }\n        return count;\n    }\n\n    bool isValid(vector<long long>& a, vector<long long>& b, vector<long long>& c, vector<long long>& d, long long k, long long prod){\n        long long count = 0;\n        \n        count += getPairsCount(b, d, prod);\n\n        reverse(a.begin(), a.end());\n        reverse(c.begin(), c.end());\n        count += getPairsCount(a, c, prod);\n        reverse(a.begin(), a.end());\n        reverse(c.begin(), c.end());\n\n        reverse(b.begin(), b.end());\n        count += getPairsCount(b, c, prod);\n        reverse(b.begin(), b.end());\n\n        reverse(d.begin(), d.end());\n        count += getPairsCount(a, d, prod);\n        reverse(d.begin(), d.end());\n        return count >= k;\n    }\n\n    long long kthSmallestProduct(vector<int>& nums1, vector<int>& nums2, long long k) {\n        int m = nums1.size();\n        int n = nums2.size();\n\n        long long p = (nums1[0] < 0) ? ((long long)nums1[0] * nums2[n - 1]) : ((long long)nums1[0] * nums2[0]);\n        long long q = (nums1[m - 1] < 0) ? ((long long)nums1[m - 1] * nums2[n - 1]) : ((long long)nums1[m - 1] * nums2[0]);\n        long long r = (nums1[m - 1] >= 0) ? ((long long)nums1[m - 1] * nums2[n - 1]) : ((long long)nums1[m - 1] * (nums2[0]));\n        long long s = (nums1[0] < 0) ? ((long long)nums1[0] * nums2[0]) : ((long long)nums1[0] * nums2[n - 1]);\n\n        long long start = min(p, q);\n        long long end = max(r, s);\n        long long mid;\n\n        vector<long long> a;\n        vector<long long> b;\n        vector<long long> c;\n        vector<long long> d;\n        int i;\n\n        for(i = 0; i < m; i++){\n            if(nums1[i] < 0){\n                a.push_back(nums1[i]);\n            }\n            else{\n                b.push_back(nums1[i]);\n            }\n        }\n\n        for(i = 0; i < n; i++){\n            if(nums2[i] < 0){\n                c.push_back(nums2[i]);\n            }\n            else{\n                d.push_back(nums2[i]);\n            }\n        }\n\n        while(start <= end){\n            mid = start + (end - start) / 2;\n            if(mid == start){\n                return isValid(a, b, c, d, k, start) ? start : end;\n            }\n            else{\n                if(isValid(a, b, c, d, k, mid)){\n                    end = mid;\n                }\n                else{\n                    start = mid;\n                }\n            }\n        }\n        return start;\n    }\n};\n```
['C++']