Finding local maxima in a 2D array

前端 未结 7 2155
生来不讨喜
生来不讨喜 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:11

    I believe this question can be answered using what is known as adversary arguments, which gives you a lower bound on the number of comparisons.

    And in my opinion, you are right.. this would require atleast n^2 comparisons.

提交回复
热议问题