C++ Binary Search Solution
\n\n# Code\n\n#define ll long long\n\nclass Solution {\n\n    bool isPossible(vector<int>& a, vector<int>& b,  ll midVal, ll k) {\n        ll cnt = 0;\n        
\n\n# Code\n```\n#define ll long long\n\nclass Solution {\n\n    bool isPossible(vector<int>& a, vector<int>& b,  ll midVal, ll k) {\n        ll cnt = 0;\n        for(auto num: a) {\n            if(num >= 0) { // smallest products will be on left side\n                \n                ll l = 0, h = b.size() - 1, res = -1;\n                while(l <= h) {\n                    ll mid = (l + h) / 2;\n\n                    if((long long) b[mid] * num <= midVal) {\n                        l = mid + 1;\n                        res = mid; // go higher because ve * -ve = -ve;\n                    } else\n                        h = mid - 1;\n                }\n                \n                cnt += res + 1; // left side to maximum side\n                \n            } else { // smallest products will be on right side\n     \n                ll l = 0, h = b.size() - 1, res = b.size();\n                while(l <= h) {\n                    ll mid = (l + h) / 2;\n\n                    if((long long) b[mid] * num <= midVal) {\n                        h = mid - 1;\n                        res = mid; // go lower because -ve * +ve = -ve\n                    } else\n                        l = mid + 1;\n                }\n                \n                cnt += b.size() - res; // left side to maximum side\n                \n            }\n        }\n\n        return cnt >= k;\n    }\n\npublic:\n    ll kthSmallestProduct(vector<int>& a, vector<int>& b, ll k) {\n        ll low = -1e10;\n        ll high = 1e10; \n        ll res = 0;\n\n        while(low <= high) {\n            ll mid = (low + high) / 2;\n            if(isPossible(a, b, mid, k)) {\n                res = mid;\n                high = mid - 1;\n            } else\n                low = mid + 1;\n        }\n\n        return res;\n    }\n};\n```
['C++']