leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1855.cpp (384B)


      1 class Solution {
      2   public:
      3     int maxDistance(const vector<int> &nums1, const vector<int> &nums2) const {
      4         const int n = size(nums1), m = size(nums2);
      5         int res = 0, i = 0, j = 0;
      6 
      7         while (i < n && j < m) {
      8             if (nums1[i] > nums2[j])
      9                 i++;
     10             else
     11                 res = max(res, j++ - i);
     12         }
     13 
     14         return res;
     15     }
     16 };