mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 12:16:14 -04:00
Update README.md
This commit is contained in:
parent
ba0780c240
commit
ac1f70506a
@ -29,7 +29,29 @@
|
||||
* in any case, this technique is usually used when the array is sorted.
|
||||
|
||||
* in the **sliding window** technique, the two pointers usually move in the same direction and never overtake each other. examples are: longest substring without repeating characters, minumum size subarray sum, minimum window substring.
|
||||
|
||||
|
||||
|
||||
----
|
||||
|
||||
### intervals
|
||||
|
||||
<br>
|
||||
|
||||
* checking if two intervals overlap:
|
||||
|
||||
```python
|
||||
def is_overlap(a, b):
|
||||
return a[0] < b[1] and b[0] < a[1]
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
* merging two intervals:
|
||||
|
||||
```python
|
||||
def merge_overlapping_intervals(a, b):
|
||||
return [min(a[0], b[0]), max(a[1], b[1])]
|
||||
```
|
||||
|
||||
|
||||
<br>
|
||||
|
Loading…
x
Reference in New Issue
Block a user