Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
increment-submatrices-by-one.json32 linesDownload Raw Back to root
1{2  "id": 2625,3  "name": "increment-submatrices-by-one",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/increment-submatrices-by-one/",6  "date": "2023-01-08",7  "task_description": "You are given a positive integer `n`, indicating that we initially have an `n x n` **0-indexed** integer matrix `mat` filled with zeroes. You are also given a 2D integer array `query`. For each `query[i] = [row1i, col1i, row2i, col2i]`, you should do the following operation: Add `1` to **every element** in the submatrix with the **top left** corner `(row1i, col1i)` and the **bottom right** corner `(row2i, col2i)`. That is, add `1` to `mat[x][y]` for all `row1i <= x <= row2i` and `col1i <= y <= col2i`. Return_ the matrix_ `mat`_ after performing every query._ **Example 1:** ``` **Input:** n = 3, queries = [[1,1,2,2],[0,0,1,1]] **Output:** [[1,1,0],[1,2,1],[0,1,1]] **Explanation:** The diagram above shows the initial matrix, the matrix after the first query, and the matrix after the second query. - In the first query, we add 1 to every element in the submatrix with the top left corner (1, 1) and bottom right corner (2, 2). - In the second query, we add 1 to every element in the submatrix with the top left corner (0, 0) and bottom right corner (1, 1). ``` **Example 2:** ``` **Input:** n = 2, queries = [[0,0,1,1]] **Output:** [[1,1],[1,1]] **Explanation:** The diagram above shows the initial matrix and the matrix after the first query. - In the first query we add 1 to every element in the matrix. ``` **Constraints:** `1 <= n <= 500` `1 <= queries.length <= 104` `0 <= row1i <= row2i < n` `0 <= col1i <= col2i < n`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "n = 3, queries = [[1,1,2,2],[0,0,1,1]]",12      "output": "[[1,1,0],[1,2,1],[0,1,1]] "13    },14    {15      "label": "Example 2",16      "input": "n = 2, queries = [[0,0,1,1]]",17      "output": "[[1,1],[1,1]] "18    }19  ],20  "constraints": [21    "Add 1 to every element in the submatrix with the top left corner (row1i, col1i) and the bottom right corner (row2i, col2i). That is, add 1 to mat[x][y] for all row1i <= x <= row2i and col1i <= y <= col2i.",22    "1 <= n <= 500",23    "1 <= queries.length <= 104",24    "0 <= row1i <= row2i < n",25    "0 <= col1i <= col2i < n"26  ],27  "python_template": "class Solution(object):\n    def rangeAddQueries(self, n, queries):\n        \"\"\"\n        :type n: int\n        :type queries: List[List[int]]\n        :rtype: List[List[int]]\n        \"\"\"\n        ",28  "java_template": "class Solution {\n    public int[][] rangeAddQueries(int n, int[][] queries) {\n        \n    }\n}",29  "metadata": {30    "func_name": "rangeAddQueries"31  }32}