Last active
August 29, 2015 14:11
-
-
Save mchail/f81828c708aecbb79f4d to your computer and use it in GitHub Desktop.
Interval merger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IntervalMerger | |
def initialize(*intervals) | |
@intervals = intervals | |
end | |
def merge | |
# TODO: return the reduced set of intervals | |
end | |
end | |
IntervalMerger.new([0, 2], [1, 4]).merge # => [[0, 4]] | |
IntervalMerger.new([0, 1], [3, 4]).merge # => [[0, 1], [3, 4]] | |
IntervalMerger.new([4, 5], [5, 6], [6, 7]).merge # => [[4, 7]] | |
IntervalMerger.new([4, 5], [2, 6]).merge # => [[2, 6]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment