Sounds like a simple serialisation question, and faster/slower array walking.
IE: If you have an NxM two dimensional array, and the first digit of a look-up is the position in X on the table, the second its Y, it will be an X fastest array(every increment in x corresponds to M increments along the Y serie).
The conversion is a simple serialisation of that table into a one dimensional sequence.
In general to answer that you need to know how you are serialising, but assuming the standard NxM X faster than Y, you can use something like:
i = X*M + Y
Basically that means every time you advance in X, you advance in the serie by the length along X (or the number of Y entries in that X), then add the Y to find the offset within that line.
That’s columns then rows, if you scanline top to bottom then usually X will be slower than Y, as a hop down by one line will be N pixels on X jumped.
edit: btw, if you’re already finding it an obstacle to map a 2d table to a serie, and you’re taking programming classes, you might want to go back to some fundamentals in a hurry. This isn’t really image manipulation specific, this is very, very simple arithmetics behind data models and data management ABC.