File: root - text - article - 2019 - 11 - merge-overlapping-intervals.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 492 Views, 20466 Search Bots | 76 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 492 Views, 20466 Search Bots | 76 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Microsoft:
You are given an array of intervals - that is, an array of tuples (start, end). The array may not be sorted, and could contain overlapping intervals. Return another array where the overlapping intervals are merged.
For example:
[(1, 3), (5, 8), (4, 10), (20, 25)]
This input should return [(1, 3), (4, 10), (20, 25)] since (5, 8) and (4, 10) can be merged into (4, 10).
Here's a starting point:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 492 Views, 20466 Search Bots | 76 Words You are given an array of intervals - that is, an array of tuples (start, end). The array may not be sorted, and could contain overlapping intervals. Return another array where the overlapping intervals are merged.
For example:
[(1, 3), (5, 8), (4, 10), (20, 25)]
This input should return [(1, 3), (4, 10), (20, 25)] since (5, 8) and (4, 10) can be merged into (4, 10).
Here's a starting point:
def merge(intervals):
# Fill this in.
print merge([(1, 3), (5, 8), (4, 10), (20, 25)])
# [(1, 3), (4, 10), (20, 25)]
Related Articles
- Daily Interview Problem: Count Number of Unival Subtrees
- Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
- Algorithm Interview: Convert Roman Numerals to Decimal
- Daily Interview Problem: Min Stack
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Daily Interview Question: Create a Simple Calculator
- Plus One
- Maximum In A Stack
- Generate All IP Addresses
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
©2006~2024 SteakOverCooked - 0.00881 Seconds(s) - 6105.982 KB/s - 35 Online Memory: 528.05 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !