|
| 1 | +{ |
| 2 | + "problem_name": "zero_one_matrix", |
| 3 | + "solution_class_name": "Solution", |
| 4 | + "problem_number": "542", |
| 5 | + "problem_title": "01 Matrix", |
| 6 | + "difficulty": "Medium", |
| 7 | + "topics": "Array, Dynamic Programming, Breadth-First Search, Matrix", |
| 8 | + "tags": ["grind-75"], |
| 9 | + "readme_description": "Given an `m x n` binary matrix `mat`, return the distance of the nearest `0` for each cell.\n\nThe distance between two cells sharing a common edge is `1`.", |
| 10 | + "readme_examples": [ |
| 11 | + { |
| 12 | + "content": "\n\n```\nInput: mat = [[0,0,0],[0,1,0],[0,0,0]]\nOutput: [[0,0,0],[0,1,0],[0,0,0]]\n```" |
| 13 | + }, |
| 14 | + { |
| 15 | + "content": "\n\n```\nInput: mat = [[0,0,0],[0,1,0],[1,1,1]]\nOutput: [[0,0,0],[0,1,0],[1,2,1]]\n```" |
| 16 | + } |
| 17 | + ], |
| 18 | + "readme_constraints": "- `m == mat.length`\n- `n == mat[i].length`\n- `1 <= m, n <= 10^4`\n- `1 <= m * n <= 10^4`\n- `mat[i][j]` is either `0` or `1`\n- There is at least one `0` in `mat`", |
| 19 | + "readme_additional": "**Note:** This question is the same as 1765: [Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak/)", |
| 20 | + "solution_imports": "", |
| 21 | + "solution_methods": [ |
| 22 | + { |
| 23 | + "name": "update_matrix", |
| 24 | + "parameters": "mat: list[list[int]]", |
| 25 | + "return_type": "list[list[int]]", |
| 26 | + "dummy_return": "[]" |
| 27 | + } |
| 28 | + ], |
| 29 | + "test_imports": "import pytest\nfrom leetcode_py.test_utils import logged_test\nfrom .solution import Solution", |
| 30 | + "test_class_name": "ZeroOneMatrix", |
| 31 | + "test_helper_methods": [ |
| 32 | + { "name": "setup_method", "parameters": "", "body": "self.solution = Solution()" } |
| 33 | + ], |
| 34 | + "test_methods": [ |
| 35 | + { |
| 36 | + "name": "test_update_matrix", |
| 37 | + "parametrize": "mat, expected", |
| 38 | + "parametrize_typed": "mat: list[list[int]], expected: list[list[int]]", |
| 39 | + "test_cases": "[([[0, 0, 0], [0, 1, 0], [0, 0, 0]], [[0, 0, 0], [0, 1, 0], [0, 0, 0]]), ([[0, 0, 0], [0, 1, 0], [1, 1, 1]], [[0, 0, 0], [0, 1, 0], [1, 2, 1]])]", |
| 40 | + "body": "result = self.solution.update_matrix(mat)\nassert result == expected" |
| 41 | + } |
| 42 | + ], |
| 43 | + "playground_imports": "from solution import Solution", |
| 44 | + "playground_test_case": "# Example test case\nmat = [[0, 0, 0], [0, 1, 0], [1, 1, 1]]\nexpected = [[0, 0, 0], [0, 1, 0], [1, 2, 1]]", |
| 45 | + "playground_execution": "result = Solution().update_matrix(mat)\nresult", |
| 46 | + "playground_assertion": "assert result == expected" |
| 47 | +} |
0 commit comments