Practice
Find a Value in a 2D Grid
MEDIUM2D Arrays8 marks
Read a 3×3 grid of integers, then a target value. Output the position of the first match in row-major order, or Not found.
Input: 9 integers (row by row), then the target integer.
Output: Found at row <r> column <c> or Not found.
Example:
Input: 1
2
3
4
5
6
7
8
9
5
Output: Found at row 2 column 2
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Value in the centre
Inputs: 1, 2, 3, 4, 5, 6, 7, 8, 9, 5
Expected: Found at row 2 column 2
Test 2: Target missing
Inputs: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Expected: Not found