CoolFace
Datasetpublic

FPEvalDataset/LeetCodeProblem

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes304downloads
1{2    "id": 3227,3    "name": "find_missing_and_repeated_values",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/find-missing-and-repeated-values/",6    "date": "2023-12-10 00:00:00",7    "task_description": "You are given a **0-indexed** 2D integer matrix `grid` of size `n * n` with values in the range `[1, n2]`. Each integer appears **exactly once** except `a` which appears **twice** and `b` which is **missing**. The task is to find the repeating and missing numbers `a` and `b`. Return _a **0-indexed **integer array _`ans`_ of size _`2`_ where _`ans[0]`_ equals to _`a`_ and _`ans[1]`_ equals to _`b`_._ **Example 1:** ``` **Input:** grid = [[1,3],[2,2]] **Output:** [2,4] **Explanation:** Number 2 is repeated and number 4 is missing so the answer is [2,4]. ``` **Example 2:** ``` **Input:** grid = [[9,1,7],[8,9,2],[3,4,6]] **Output:** [9,5] **Explanation:** Number 9 is repeated and number 5 is missing so the answer is [9,5]. ``` **Constraints:** `2 <= n == grid.length == grid[i].length <= 50` `1 <= grid[i][j] <= n * n` For all `x` that `1 <= x <= n * n` there is exactly one `x` that is not equal to any of the grid members. For all `x` that `1 <= x <= n * n` there is exactly one `x` that is equal to exactly two of the grid members. For all `x` that `1 <= x <= n * n` except two of them there is exactly one pair of `i, j` that `0 <= i, j <= n - 1` and `grid[i][j] == x`.",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "grid = [[1,3],[2,2]]",12            "output": "[2,4] "13        },14        {15            "label": "Example 2",16            "input": "grid = [[9,1,7],[8,9,2],[3,4,6]]",17            "output": "[9,5] "18        }19    ],20    "private_test_cases": [],21    "haskell_template": "findMissingAndRepeatedValues :: [[Int]] -> [Int]\nfindMissingAndRepeatedValues grid ",22    "ocaml_template": "let findMissingAndRepeatedValues (grid: int list list) : int list =  ",23    "scala_template": "def findMissingAndRepeatedValues(grid: List[List[Int]]): List[Int] = { \n    \n}",24    "java_template": "class Solution {\n    public int[] findMissingAndRepeatedValues(int[][] grid) {\n        \n    }\n}",25    "python_template": "class Solution(object):\n    def findMissingAndRepeatedValues(self, grid):\n        \"\"\"\n        :type grid: List[List[int]]\n        :rtype: List[int]\n        \"\"\"\n        "26}