From ac1f70506a0ad30a47112ba4cfe208fa29379362 Mon Sep 17 00:00:00 2001 From: bt3gl <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Tue, 8 Aug 2023 17:10:49 -0700 Subject: [PATCH] Update README.md --- arrays_and_strings/README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/arrays_and_strings/README.md b/arrays_and_strings/README.md index 8b58178..25daa0d 100644 --- a/arrays_and_strings/README.md +++ b/arrays_and_strings/README.md @@ -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 + +
+ +* checking if two intervals overlap: + +```python +def is_overlap(a, b): + return a[0] < b[1] and b[0] < a[1] +``` + +
+ +* merging two intervals: + +```python +def merge_overlapping_intervals(a, b): + return [min(a[0], b[0]), max(a[1], b[1])] +```