Selecting every nth item from an array

后端 未结 8 1945
春和景丽
春和景丽 2021-02-02 13:41

What would be the most efficient way to select every nth item from a large array? Is there a \'smart\' way to do it or is looping the only way?

Some points to c

8条回答
  •  轮回少年
    2021-02-02 14:15

    • Create a two dimentional array [205][N]
    • Load data into array
    • Access 205th element for every N

    May sound silly but by definition it is fastest since you access memory locations directly and do not perform any comparisons.

提交回复
热议问题