3 ms·
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!
by timwis 4y ago
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!
- philz99 4y ago
- awild 4y agoSort by lowest start, merge left when they overlap. Emit current span if not. Repeat.
- badelectron 4y agoIf 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 https://xlinux.nist.gov/dads/HTML/discretintrv.html