Consider $N$ points that are located on a 2D plane where the $i$-th point’s location is denoted as $(x_i, y_i)$.
Is there any efficient algorithm that can compute $d_i$ that is defined as the number of points with $x<x_i$ and $y<y_i$ for all $i$? In other words, we would like to count the number of points on the lower left of point $i$. To simplify, assume there’s no pair of points that have the exact same $x$ and $y$.
By “efficient”, I mean the complexity should be $O(N\log N)$ (in runtime and memory) or better.
EDIT: Adding the specification for the algorithm: The input to the algorithm is a list of the coordinate of the points (not necessarily sorted in any order) and the output will be a list where the $i$-th element is the number of points in the lower left of the $i$-th points.