Let $L_{1},L_{2},...,L_{n}$ be a sequence of numbers, and let $i, j$ be the indexes such that $1 \leq i<j \leq n$.
I need to find the amount of numbers that satisfy $L_{i}<2 L_{j}$ with time complexity $\mathcal O\,(n \cdot log(n))$
Let $L_{1},L_{2},...,L_{n}$ be a sequence of numbers, and let $i, j$ be the indexes such that $1 \leq i<j \leq n$.
I need to find the amount of numbers that satisfy $L_{i}<2 L_{j}$ with time complexity $\mathcal O\,(n \cdot log(n))$
As the title suggests you will need to apply a divide and conquer idea. So the difficult part is the merge part. Let the following pseudo-code
Since the merge is done in $\mathcal O(n)$ so the complexity is $\mathcal O(n\log(n))$.