[CareerCup 9.6] 排序矩阵查找

Given a matrix in which each row and each column is sorted, write a method to find an element in it.

Assumptions:
»»Rows are sorted left to right in ascending order. Columns are sorted top to bottom in ascending order.
»»Matrix is of size MxN.
This algorithm works by elimination. Every move to the left (--col) eliminates all the elements below the current cell in that column. Likewise, every move down eliminates all the elements to the left of the cell in that row.

image

posted on 2011-12-22 22:41  小橋流水  阅读(157)  评论(0编辑  收藏  举报

导航