To the Top
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 | 181 Views, 15462 Search Bots | 76 Words

Subscribe to Feed Burner | 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:


def merge(intervals):
# Fill this in.

print merge([(1, 3), (5, 8), (4, 10), (20, 25)])
# [(1, 3), (4, 10), (20, 25)]
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 181 Views, 15462 Search Bots | 76 Words Subscribe to Feed Burner

Related Articles

  1. Algorithm Interview Question: Symmetric k-ary Tree
  2. Algorithm Interview: Permutations of numbers
  3. Daily Interview Puzzle: Intersection of Linked Lists
  4. Most Frequent Subtree Sum
  5. Algorithm Interview Question: Max and Min with Limited Comparisons
  6. Daily Interview Question: Find Cycles in a Graph
  7. Algorithm Interview: Maximum Path Sum in Binary Tree
  8. Daily Interview Problem: 3 Sum
  9. Find the non-duplicate number
  10. [Daily Problem] Witness of The Tall People

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />