Binary Search in 2D Array

后端 未结 8 1112
南笙
南笙 2021-02-09 17:14

I wonder, can binary search be applied on a 2D array?

  • What would the conditions on the array be? Sorted on 2D??
8条回答
  •  囚心锁ツ
    2021-02-09 17:40

    You can transform 2D array into 1D array and do the binary search here. Complexity is O(log(m * n)) for mxn array.

提交回复
热议问题