PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000090. Tìm số trong ma trận có thứ tự (Search a 2D Matrix)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tìm số trong ma trận có thứ tự (Search a 2D Matrix)
Search a 2D Matrix
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer matrix whose rows are non-decreasing and whose first element of each row is greater than the last element of the previous row, determine whether occurs.
Input
The first line contains . Each of the next lines contains exactly matrix entries.
Output
Print true if is present, otherwise false.
Subtasks
- Subtask 1 (20 points): ; ; each row is non-decreasing and each next row starts with a greater value than the previous row ends.
- Subtask 2 (30 points): ; ; each row is non-decreasing and each next row starts with a greater value than the previous row ends.
- Subtask 3 (50 points): ; ; each row is non-decreasing and each next row starts with a greater value than the previous row ends.
Examples
Input
3 4 3
1 3 5 7
10 11 16 20
23 30 34 60
Output
true
Explanation
The entry in row , column equals the target , so the answer is true.