I don't know for sure if the following answer wasn't provided
but I decided to add some local optimizations to the allocation of 2d array
(e.g., a square matrix is done through only one allocation):
int** mat = new int*[n];
mat[0] = new int [n * n];
However, deletion goes like this because of linearity of the allocation above:
delete [] mat[0];
delete [] mat;