Nokia Interview Question

optimized memory allocation for matrix