Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
timwis
· 4y ago · 0 comments
Wow, I was just trying to solve the problem of merging overlapping periods in ruby. Life would be so much easier if the database did it for me!
Comments
[–]
awild
4y ago
Sort by lowest start, merge left when they overlap. Emit current span if not. Repeat.
[–]
badelectron
4y ago
If you want to do this with a data structure instead of a database then discrete interval encoding trees solve this problem well.
https://xlinux.nist.gov/dads/HTML/discretintrv.html