Skip to content

Commit 6fbde74

Browse files
committed
Fix overlap algo
1 parent 8f2b75e commit 6fbde74

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

algorithms/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ def traverse(matrix):
266266
- Be familiar with writing code to check if two intervals overlap and merging two overlapping intervals:
267267

268268
```py
269-
def is_overlap(intvl1, intvl2):
270-
return intvl2[0] < intvl1[1] < intvl2[1] or intvl1[0] < intvl2[1] < intvl1[1]
269+
def is_overlap(a, b):
270+
return a[0] < b[1] and b[0] < a[1]
271271

272-
def merge_overlapping_intervals(intvl1, intvl2):
273-
return [min(intvl1[0], intvl2[0]), max(intvl1[1], intvl2[1])]
272+
def merge_overlapping_intervals(a, b):
273+
return [min(a[0], b[0]), max(a[1], b[1])]
274274
```
275275

276276
##### Questions

0 commit comments

Comments
 (0)