When most of the elements in an array are 0 or an array of the same value, a sparse array can be used to save the array.
The sparse array is handled as follows: 1. Record the total number of rows and columns in the array, and how many different values are there. 2. Record the elements with different values, rows, columns and values in a small array, thereby reducing the size of the program
As shown below: the left is the original array, the right is the sparse array