Loading...
Loading...
Loading...
A grid has r rows and c columns. Every row is sorted ascending, and the first number of each row is larger than the last number of the row above. Print yes if the target is in the grid and no otherwise.
Example
Input
3 4 1 3 5 7 10 11 16 20 23 30 34 60 11
Output
yes
Try the problem first. Open one hint at a time.
Because each row starts above the previous row ends, reading the grid row by row gives one long sorted list.
Position p of that list is row p // c, column p % c.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor