Skip to content

Instantly share code, notes, and snippets.

View joeghodsi's full-sized avatar

Joe Ghodsi joeghodsi

  • San Francisco, CA
View GitHub Profile
findOverlappingIntervals = (intervals) ->
# throw all dates into an array. each date object also knows whether it is a start or end
# date. after sorting, each start you hit signifies an interval. each end you hit signifies an
# interval ends. if the interval counter is greater than zero, it means there is an overlap
# construct list of start and end dates from all intervals
dates = []
for interval, index in intervals
startElement =
type: 'start'