...
Let's pretend we're working on a computer vision project. In this project,
librarians sent us videos of their bookshelves. Based on frames from these videos,
we want to quickly and efficiently find the spine tags on the library books.
For the purposes of the interview, we'll be simplifying this to the following problem.
input matrix - m x n = m ~ n = all 0s
spine tag - square of 1s
000000000000
000000000000
000000000000
000000000000
000001111000
000001111000
000001111000
000001111000
000000000000
000000000000
这道谷歌面试题将原本的计算机视觉问题简化成一个二维矩阵问题:矩阵几乎全是 0,只包含一个由 1 组成的正方形区域,代表书脊标签。你的任务是高效找出这个正方形的起点坐标与边长。解法一般会利用连续 1 的结构特征、前缀和矩阵或动态规划等方式,让整体时间复杂度接近 O(mn),而不是暴力的 O(mn·min(m,n))。
正文完