Original website: https://www.lintcode.com/zh-cn/old/problem/search-a-2d-matrix-ii/#
38. Search two-dimensional matrix II
Write an efficient algorithm to search the values in the m x n matrix and return the number of times that value occurs.
This matrix has the following properties:
- The integers in each line are sorted from left to right.
- The integers in each column are sorted from top to bottom.
- There are no repeating integers in every row or column.
Consider the following matrix:
[1, 3, 5, 7],
[2, 4, 7, 8],
[3, 5, 9, 10]
Give target = =3，Return 2
O (m+n) time complexity and O (1) extra space