Given a set of intervals S what is the efficient way to find the number of subsets assigned to each interval from the set S.
say for example
S = (11,75), (14,62), (17,32), (24,48), (31,71), (34,74), (40,97), (41,58)
as for output
(11, 75) => 6 -> (14,62), (17,32), (24,48), (31,71), (34,74), (41,58)
(14, 62) => 3 -> (17,32), (24,48), (41,58)
(17, 32) => 0
(24, 48) => 0
(31, 71) => 1 -> (41,58)
(34, 74) => 1 -> (41,58)
(40, 97) => 1 -> (41,58)
(41, 58) => 0
Is it possible to get this mapping in o(nlogn) or substantially less than o(n2)?