Matrix Madness
For example, for N=6, we might have the matrix:
0 1 2 3 4 5
1 0 3 2 5 4
2 3 0 1 6 7
3 2 1 0 7 6
4 5 6 7 0 1
5 4 7 6 1 0
We wish to find, for an arbitrary N, an N x N matrix with the following property: each entry in the matrix is the smallest non-negative number which does not appear either above the entry or to its left.
-
Write a function that computes the entry in a particular row and column. That is, complete the following:
int entry_at(int row, int column) { // ... } Can you write the entry_at function to run in constant space and constant time?
Can you prove that your algorithm is correct?
Please send your solution (and your resume if you have one ready) to challenge@rapleaf.com.

Follow