View smallest_time_interval.ex
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
defmodule SmallestTimeInterval do | |
@moduledoc """ | |
Given a list of times in a 24-hour period, return the smallest interval between two times in the list. Hint: you can | |
do this in O(n) time! Assume the list is unsorted. | |
Example: | |
$ smallestTimeInterval(['01:00', '08:15', '11:30', '13:45', '14:10', '20:05']) | |
$ '25 minutes' |