JAVA-sparse array introduction

JAVA-sparse array introduction


  1. 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.
  2. 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
  3. As shown below: the left is the original array, the right is the sparse array
  4. Sparse array

Guess you like

Origin blog.csdn.net/qq_39453420/article/details/108457392