Skip to content

Instantly share code, notes, and snippets.

@davemaurer
Created July 13, 2015 21:49
Show Gist options
  • Save davemaurer/cf8c5c6fff6ee7dc80cb to your computer and use it in GitHub Desktop.
Save davemaurer/cf8c5c6fff6ee7dc80cb to your computer and use it in GitHub Desktop.
class HistogramRectangle
def initialize(histogram)
@hist = histogram
end
def find_rectangle
area = []
@hist.each_with_index do |coords, index|
@new_index = (index + 1)
@x_coord = 1
until @hist.length <= @new_index || @hist[@new_index][1] < coords[1]
@new_index += 1
@x_coord += 1
end
area.push(@x_coord * coords[1])
end
area.max
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment