C++ || Simple Binary Search || Easy to understand
class Solution {\npublic:\n\n    int maxDistance(vector& arr1, vector& arr2) {\n        int n = arr1.size(), ans = 0;\n        \n        for(int i = 0; i < n; i
class Solution {\npublic:\n\n    int maxDistance(vector<int>& arr1, vector<int>& arr2) {\n        int n = arr1.size(), ans = 0;\n        \n        for(int i = 0; i < n; i++){\n            int x = arr1[i];\n            \n            int l = i , h = arr2.size()-1, j = -1;\n            \n            while(l <= h){\n                \n                int m = l + (h-l)/2;\n                \n                if(x <= arr2[m]){\n                    j = m;\n                    l = m+1;\n                }\n                else h = m-1;\n            }\n            \n            ans = max(ans,j-i);\n        }\n        return ans;\n    }\n};
['C', 'Binary Tree', 'C++']