Advertisement
nikunjsoni

1855

May 9th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int maxDistance(vector<int>& n1, vector<int>& n2) {
  4.         int i = 0, j = 0, res = 0;
  5.         while (i < n1.size() && j < n2.size()) {
  6.             if (n1[i] > n2[j])
  7.                 ++i;
  8.             else
  9.                 res = max(res, j++ - i);
  10.         }
  11.         return res;
  12.     }
  13. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement