Check out example codes for "array 2d to 1d". It will help you in understanding the concepts better.

Code Example 1

int array[width * height];

 int SetElement(int row, int col, int value)
 {
    array[width * row + col] = value;  
 }

Learn ReactJs, React Native from akashmittal.com