← Back to Data Structures & Algorithms
Question 552
Search A Grid
Search A Grid
Write search_grid(grid: list[list[int]], target: int) -> tuple[int, int] that returns the (row, col) position of the first cell equal to target, scanning row by row and left to right with the two given loops, or (-1, -1) when the grid does not hold it. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: the number of rows, then one line of space-separated integers per row, then the target; the tests build the grid and print the tuple your function returns.
Expected Output:
(1, 1)= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Data Structures & Algorithms
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.