c# : Easy Solution
Solution 1:\n\n\n\npublic class Solution {\n  public int MaxDistance(int[] nums1, int[] nums2) {\n    int ans = 0, i = nums1.Length - 1, j = nums2.Length - 1;\n
**Solution 1:**\n\n```\n\npublic class Solution {\n  public int MaxDistance(int[] nums1, int[] nums2) {\n    int ans = 0, i = nums1.Length - 1, j = nums2.Length - 1;\n\n    while(i >= 0 && j >= 0) {\n      if(i > j) {\n        i--;\n        continue;\n      }\n\n      if(nums1[i] <= nums2[j]) {\n        ans = Math.Max(ans, Math.Abs(j - i));\n        i--;\n      }\n      else\n        j--;\n    }\n\n    return ans;\n  }\n}\n```\n\n**Solution 2:**\n\n```\npublic class Solution {\n  public int MaxDistance(int[] nums1, int[] nums2) {\n      int ans = 0, low = 0, high = nums2.Length;\n      while(low <= high) {\n          var mid = low + (high - low) / 2;\n          if(IsPossible(nums1, nums2, mid)) {\n              ans = Math.Max(ans, mid);\n              low = mid + 1;\n          }\n          else\n              high = mid - 1;\n      }\n\n      return ans;\n  }\n\n  private bool IsPossible(int[] nums1, int[] nums2, int dist) {\n      for(int i = 0, j = dist; i < nums1.Length && j < nums2.Length; i++, j++) {\n          if(nums1[i] <= nums2[j])\n              return true;\n      }\n\n      return false;\n  }\n}\n```
['Two Pointers', 'Binary Search']