In the ranks are sorted matrix to find the specified number

1: Title Description

Title Description

Given a N \ Times M N × M matrix plastic matrix and an integer K, matrix each row and each column are sorted.
Implement a function, in the matrix determines whether the K
[Claim]
Time complexity is O (N + M) O ( N + M ), additional space complexity is O (. 1) O ( . 1 ).

Enter a description:

The first line contains three integers N, M, K 
Next N lines of M integers input matrix

Output Description:

K output if there is "Yes" in the matrix, or the output of "No"
Example 1

Entry

2 4 5
1 2 3 4
2 4 5 6

Export

Yes
Example 2

Entry

2 4 233
1 2 3 4
2 4 5 6

Export

No 

2: Title Analysis

3: Code Example

Guess you like

Origin www.cnblogs.com/dazhu123/p/12560813.html