Easy C++ Solution || Binary Search || O(nlogn) ✔
\n## Code\n\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int dis=0;\n        for (int i=0; i<nums1.size();
\n## Code\n```\nclass Solution {\npublic:\n    int maxDistance(vector<int>& nums1, vector<int>& nums2) {\n        int dis=0;\n        for (int i=0; i<nums1.size(); i++){\n            int low= i+1; int high= nums2.size()-1;// int midi=i;\n            while (low<=high){\n                int mid= low+ (high-low)/2;\n                if (nums1[i]>nums2[mid]){\n                    high= mid-1;\n                }\n                else {low= mid+1;}\n            }\n            dis= max(dis,low-1-i);\n        }\n        return dis;\n    }\n};\n```\n### Complexity\n- Time complexity: $$O(nlogm),$$\n *n is the size of nums1\n m is the size of nums2*\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$ O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n
['C++']