Skip to content

Commit 8af1290

Browse files
authored
Create maximum-distance-between-a-pair-of-values.py
1 parent 4ef1f90 commit 8af1290

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Time: O(n + m)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def maxDistance(self, nums1, nums2):
6+
"""
7+
:type nums1: List[int]
8+
:type nums2: List[int]
9+
:rtype: int
10+
"""
11+
result = i = j = 0
12+
while i < len(nums1) and j < len(nums2):
13+
if nums1[i] > nums2[j]:
14+
i += 1
15+
else:
16+
result = max(result, j-i)
17+
j += 1
18+
return result

0 commit comments

Comments
 (0)