| { |
| "id": 3415, |
| "name": "check_if_grid_satisfies_conditions", |
| "difficulty": "Easy", |
| "link": "https://leetcode.com/problems/check-if-grid-satisfies-conditions/", |
| "date": "2024-04-27 00:00:00", |
| "task_description": "You are given a 2D matrix `grid` of size `m x n`. You need to check if each cell `grid[i][j]` is: Equal to the cell below it, i.e. `grid[i][j] == grid[i + 1][j]` (if it exists). Different from the cell to its right, i.e. `grid[i][j] != grid[i][j + 1]` (if it exists). Return `true` if **all** the cells satisfy these conditions, otherwise, return `false`. **Example 1:** **Input:** grid = [[1,0,2],[1,0,2]] **Output:** true **Explanation:** **** All the cells in the grid satisfy the conditions. **Example 2:** **Input:** grid = [[1,1,1],[0,0,0]] **Output:** false **Explanation:** **** All cells in the first row are equal. **Example 3:** **Input:** grid = [[1],[2],[3]] **Output:** false **Explanation:** Cells in the first column have different values. **Constraints:** `1 <= n, m <= 10` `0 <= grid[i][j] <= 9`", |
| "public_test_cases": [ |
| { |
| "label": "Example 1", |
| "input": "grid = [[1,0,2],[1,0,2]]", |
| "output": "true " |
| }, |
| { |
| "label": "Example 2", |
| "input": "grid = [[1,1,1],[0,0,0]]", |
| "output": "false " |
| }, |
| { |
| "label": "Example 3", |
| "input": "grid = [[1],[2],[3]]", |
| "output": "false " |
| } |
| ], |
| "private_test_cases": [ |
| { |
| "input": [ |
| [ |
| 7, |
| 6, |
| 4, |
| 7, |
| 1, |
| 8, |
| 9, |
| 7 |
| ], |
| [ |
| 3, |
| 8, |
| 3, |
| 5, |
| 3, |
| 7, |
| 6, |
| 6 |
| ], |
| [ |
| 3, |
| 2, |
| 7, |
| 1, |
| 3, |
| 1, |
| 1, |
| 4 |
| ], |
| [ |
| 0, |
| 2, |
| 4, |
| 9, |
| 3, |
| 1, |
| 4, |
| 5 |
| ], |
| [ |
| 0, |
| 2, |
| 9, |
| 7, |
| 5, |
| 3, |
| 4, |
| 1 |
| ], |
| [ |
| 1, |
| 5, |
| 4, |
| 4, |
| 9, |
| 6, |
| 9, |
| 3 |
| ], |
| [ |
| 2, |
| 9, |
| 8, |
| 5, |
| 3, |
| 7, |
| 2, |
| 1 |
| ], |
| [ |
| 9, |
| 4, |
| 0, |
| 6, |
| 1, |
| 7, |
| 4, |
| 1 |
| ], |
| [ |
| 5, |
| 9, |
| 9, |
| 6, |
| 5, |
| 6, |
| 5, |
| 8 |
| ], |
| [ |
| 4, |
| 0, |
| 7, |
| 1, |
| 6, |
| 2, |
| 9, |
| 7 |
| ] |
| ], |
| "output": false |
| }, |
| { |
| "input": [ |
| [ |
| 0, |
| 9 |
| ], |
| [ |
| 1, |
| 5 |
| ], |
| [ |
| 0, |
| 1 |
| ], |
| [ |
| 9, |
| 9 |
| ], |
| [ |
| 9, |
| 7 |
| ], |
| [ |
| 0, |
| 0 |
| ], |
| [ |
| 4, |
| 6 |
| ], |
| [ |
| 0, |
| 8 |
| ], |
| [ |
| 0, |
| 9 |
| ] |
| ], |
| "output": false |
| }, |
| { |
| "input": [ |
| [ |
| 9, |
| 8, |
| 8, |
| 3, |
| 0, |
| 8, |
| 7, |
| 9, |
| 9, |
| 4 |
| ], |
| [ |
| 1, |
| 9, |
| 9, |
| 0, |
| 2, |
| 9, |
| 7, |
| 1, |
| 9, |
| 9 |
| ], |
| [ |
| 3, |
| 0, |
| 6, |
| 8, |
| 3, |
| 6, |
| 5, |
| 0, |
| 2, |
| 0 |
| ], |
| [ |
| 8, |
| 1, |
| 1, |
| 7, |
| 2, |
| 2, |
| 3, |
| 1, |
| 0, |
| 8 |
| ], |
| [ |
| 5, |
| 4, |
| 5, |
| 5, |
| 2, |
| 7, |
| 8, |
| 6, |
| 8, |
| 2 |
| ], |
| [ |
| 1, |
| 0, |
| 8, |
| 8, |
| 2, |
| 1, |
| 1, |
| 4, |
| 4, |
| 6 |
| ] |
| ], |
| "output": false |
| }, |
| { |
| "input": [ |
| [ |
| 9, |
| 8, |
| 0, |
| 7 |
| ], |
| [ |
| 7, |
| 8, |
| 9, |
| 4 |
| ], |
| [ |
| 5, |
| 1, |
| 7, |
| 6 |
| ], |
| [ |
| 0, |
| 2, |
| 1, |
| 3 |
| ], |
| [ |
| 4, |
| 1, |
| 4, |
| 7 |
| ], |
| [ |
| 6, |
| 4, |
| 6, |
| 0 |
| ], |
| [ |
| 0, |
| 8, |
| 1, |
| 3 |
| ], |
| [ |
| 9, |
| 5, |
| 3, |
| 8 |
| ] |
| ], |
| "output": false |
| }, |
| { |
| "input": [ |
| [ |
| 3 |
| ], |
| [ |
| 1 |
| ], |
| [ |
| 9 |
| ] |
| ], |
| "output": false |
| } |
| ], |
| "haskell_template": "satisfiesConditions :: [[Int]] -> Bool\nsatisfiesConditions grid ", |
| "ocaml_template": "let satisfiesConditions (grid: int list list) : bool = ", |
| "scala_template": "def satisfiesConditions(grid: List[List[Int]]): Boolean = { \n \n}", |
| "java_template": "class Solution {\n public boolean satisfiesConditions(int[][] grid) {\n \n }\n}", |
| "python_template": "class Solution(object):\n def satisfiesConditions(self, grid):\n \"\"\"\n :type grid: List[List[int]]\n :rtype: bool\n \"\"\"\n " |
| } |