Assuming I have lots of time periods identified by starting and ending timestamp. What would be the quickest way to detect which period overlaps on which periods?
Here is an example:
9 different periods, delimited by a starting (from) and ending (to) timestamp.
A = [ from : 7s , to : 11s]
B = [ from : 1s, to : 8s]
C = [ from : 9s, to : 12s]
D = [ from : 4s, to : 7s]
E = [ from 10s, to: 15s]
F = [ from 0s, to : 5s]
G (oops I skipped it when drawing the image!)
H = [ from: 5s, to: 9s]
I = [ from: 11s, to: 13s]
J = [ from: 7s, to: 14s]
How to retrieve all overlapping periods as quick as possible to get the following result?
[[A,B],[A,C],[A,E],[A,H],[A,J],[B,D],[B,F],[B,H],[B,J],[C,E],[C,I],[C,J],[D,F],[D,H],[D,J],[E,I],[E,J],[H,J],[I,J]]
JSFiddle of my own solution here
And an other similar jsfiddle but this time with real timestamps, from January to March 2017 between 8 am to 18 pm EDT, and there is a lot of them.
JSFiddle with lots of timestamps
If someone can find a quicker way to proceed, that would be great! Each milliseconds is precious for me.