Finding in a two-dimensional array

Source: Internet
Author: User

Source of the topic:
  http://ac.jobdu.com/problem.php?pid=1384
Title Description:

In a two-dimensional array, each row is ordered in ascending order from left to right, and each column is sorted in ascending order from top to bottom. Complete a function, enter a two-dimensional array and an integer to determine if the array contains the integer.

Input:

The input may contain multiple test samples, for each test case,

The first behavior of the input two integers m and n (1<=m,n<=1000): Represents the number of rows and columns of the matrix that will be entered.

The second line of input includes an integer t (1<=t<=1000000): Represents the number to find.

The next M-line, each row has n number, represents the title of the M-row N-column matrix (The matrix as shown in the title description, each row is ordered from left to right increments, each column is sorted from top to bottom in order.

Output:

corresponding to each test case,

The output "Yes" indicates that a number T is found in a two-dimensional array.

The output "No" indicates that no number T is found in the two-dimensional array.

Sample input:
3 351 2 34 5 67 8 93 312 3 45 6 78 9 103 3122 3 45 6 78 9 10
Sample output:
Yesnono
Ideas:

Finding in a two-dimensional array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.