Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. /*
  2. Given a list of intervals:
  3. example: [
  4. {7, 9},
  5. {2, 4},
  6. {1, 3},
  7. {3, 5},
  8. {2, 5},
  9. {4, 6}
  10. ]
  11.  
  12. write a function that merges overlapping intervals.
  13. example output/return: [
  14. {7, 9},
  15. {1, 6}
  16. ]
  17. */
  18.  
  19. /*
  20. Interval => Span of time, with start and end
  21. the start time for a given interval is always less than or equal to the end time
  22. the start and end times are always positive integers
  23.  
  24. |-------|
  25. |--------|
  26. |--------------| -> overlap
  27.  
  28. |-------|
  29. |------|
  30. |--------------| -> overlap
  31.  
  32. |-----|
  33. |------|
  34. |-----| |------| -> no overlap
  35. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement