|
| 1 | +{ |
| 2 | + "problem_name": "spiral_matrix", |
| 3 | + "class_name": "SpiralMatrix", |
| 4 | + "method_name": "spiral_order", |
| 5 | + "problem_number": "54", |
| 6 | + "problem_title": "Spiral Matrix", |
| 7 | + "difficulty": "Medium", |
| 8 | + "topics": "Array, Matrix, Simulation", |
| 9 | + "tags": ["grind-75"], |
| 10 | + "problem_description": "Given an m x n matrix, return all elements of the matrix in spiral order.", |
| 11 | + "examples": [ |
| 12 | + { "input": "matrix = [[1,2,3],[4,5,6],[7,8,9]]", "output": "[1,2,3,6,9,8,7,4,5]" }, |
| 13 | + { |
| 14 | + "input": "matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]", |
| 15 | + "output": "[1,2,3,4,8,12,11,10,9,5,6,7]" |
| 16 | + } |
| 17 | + ], |
| 18 | + "constraints": "- m == matrix.length\n- n == matrix[i].length\n- 1 <= m, n <= 10\n- -100 <= matrix[i][j] <= 100", |
| 19 | + "parameters": "matrix: list[list[int]]", |
| 20 | + "return_type": "list[int]", |
| 21 | + "dummy_return": "[]", |
| 22 | + "imports": "", |
| 23 | + "test_cases": [ |
| 24 | + { |
| 25 | + "args": [ |
| 26 | + [ |
| 27 | + [1, 2, 3], |
| 28 | + [4, 5, 6], |
| 29 | + [7, 8, 9] |
| 30 | + ] |
| 31 | + ], |
| 32 | + "expected": [1, 2, 3, 6, 9, 8, 7, 4, 5] |
| 33 | + }, |
| 34 | + { |
| 35 | + "args": [ |
| 36 | + [ |
| 37 | + [1, 2, 3, 4], |
| 38 | + [5, 6, 7, 8], |
| 39 | + [9, 10, 11, 12] |
| 40 | + ] |
| 41 | + ], |
| 42 | + "expected": [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7] |
| 43 | + }, |
| 44 | + { "args": [[[1]]], "expected": [1] }, |
| 45 | + { |
| 46 | + "args": [ |
| 47 | + [ |
| 48 | + [1, 2], |
| 49 | + [3, 4] |
| 50 | + ] |
| 51 | + ], |
| 52 | + "expected": [1, 2, 4, 3] |
| 53 | + } |
| 54 | + ], |
| 55 | + "param_names": "matrix, expected", |
| 56 | + "param_names_with_types": "matrix: list[list[int]], expected: list[int]", |
| 57 | + "input_description": "matrix={matrix}", |
| 58 | + "input_params": "matrix", |
| 59 | + "expected_param": "expected", |
| 60 | + "method_args": "matrix", |
| 61 | + "test_setup": "", |
| 62 | + "test_logging": "", |
| 63 | + "assertion_code": "assert result == expected", |
| 64 | + "test_input_setup": "# Example test case\nmatrix = [[1,2,3],[4,5,6],[7,8,9]]", |
| 65 | + "expected_output_setup": "expected = [1,2,3,6,9,8,7,4,5]" |
| 66 | +} |
0 commit comments