Add a range to sorted ranges
ranges is a list of closed ranges [start, end], sorted by start, where no two overlap or touch. Add the range new and return the list still sorted and still without overlaps, merging new with every range it overlaps. Ranges that share an endpoint, like [1, 4] and [4, 6], count as overlapping.
ranges may be empty and values can be negative. Aim for one O(n) pass, without sorting again.
Examples
add_range([[1,3],[6,9]], [2,5])→[[1,5],[6,9]]add_range([[0,2],[4,6],[8,9],[11,15]], [5,12])→[[0,2],[4,15]]add_range([[1,4],[9,12]], [6,7])→[[1,4],[6,7],[9,12]]