In O(1) get the coordinate i,j of a diagonally ordered matrix
These are triangular numbers, so:
$i = \lfloor(-0.5 + \sqrt{0.25 + 2 * n}\rfloor - 1\\
triangular = \frac{i * (i + 1)}{2}\\
j = n - triangular - 1$

Minus one comes from indexing from 1.