Finding local maxima in a 2D array

前端 未结 7 2181
生来不讨喜
生来不讨喜 2021-02-03 12:39

A local maximum in a 2D array can be defined as a value such that all it\'s 4 neighbours are less than or equal to it, ie, for a[i][j] to be a local maximum,

7条回答
  •  没有蜡笔的小新
    2021-02-03 13:26

    Above answers just defend a mathematical model.
    Which result from a simplistic view of the problem.

    If you work as a programmer, you should know what a processor can do. And you should be aware that code runs in a thread. You should wonder if a task is sub-dividable in smaller tasks, so you be able to work it out multi-threaded and get near a 1/total-threads execution speed-up.

    The code to do that depends on the language, so I don't provide an example here.

提交回复
热议问题