A 3D matrix is to be stored in a 1D vector (flattened). The 3D matrix is of size n x m x p and is indexed by i, j, k. The 1D vector is of size q and is indexed by y.
Implement the following functions:
- Create a 1D vector suitable for storing the 3D matrix.
- Convert the 3D matrix index (i, j, k) to a suitable 1D vector index (y). Must be O(1).
O(n*m*p)
C++