How to count an infinity set? For example, all the points in a 2-D space which have positive integer coordinates. lanran finds a way to solve that, ‘Down, Right and Up!’ Let’s see how we count first several points by the above way.
How do we count more?
Hopefully, you have understood this procedure well. Similarly, we can expand the ‘matrix’ to infinitely large, that is, we can count all the points which have positive integer coordinates in a 2-D space.
Given a coordinate, you need to return its index and given an index, you need to return its coordinate.