There are $n$ intervals on the real line , the intervals are given with start- and end point. The $i$-th interval is $(d_i,f_i)$ where $d_i$ is the start point and $f_i$ is the end point$d_i<f_i$. it is given that $d_i,f_i\in \mathbb Z$ and $0<d_i,f_i<n^4$
Write an algorithm that checks if all intervals are disjoint.
e.g for $n=3\qquad (2,5),(6,7),(1,4)$ the algorithm will return
because $3$ is common for $(1,4),(2,5)$
For $n=2\qquad (6,7),(1,4)$ the algorithm will return
I've been stuck for a couple of hours, I thought maybe I could put all pairs of points into an array but I'm not sure if I should sort the array or not. Any hints please on how to approach this question?