FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3639,3 "name": "zero-array-transformation-i",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/zero-array-transformation-i/",6 "date": "2024-11-10",7 "task_description": "You are given an integer array `nums` of length `n` and a 2D array `queries`, where `queries[i] = [li, ri]`. For each `queries[i]`: Select a subset of indices within the range `[li, ri]` in `nums`. Decrement the values at the selected indices by 1. A **Zero Array** is an array where all elements are equal to 0. Return `true` if it is _possible_ to transform `nums` into a **Zero Array **after processing all the queries sequentially, otherwise return `false`. **Example 1:** **Input:** nums = [1,0,1], queries = [[0,2]] **Output:** true **Explanation:** **For i = 0:** Select the subset of indices as `[0, 2]` and decrement the values at these indices by 1. The array will become `[0, 0, 0]`, which is a Zero Array. **Example 2:** **Input:** nums = [4,3,2,1], queries = [[1,3],[0,2]] **Output:** false **Explanation:** **For i = 0:** Select the subset of indices as `[1, 2, 3]` and decrement the values at these indices by 1. The array will become `[4, 2, 1, 0]`. **For i = 1:** Select the subset of indices as `[0, 1, 2]` and decrement the values at these indices by 1. The array will become `[3, 1, 0, 0]`, which is not a Zero Array. **Constraints:** `1 <= nums.length <= 105` `0 <= nums[i] <= 105` `1 <= queries.length <= 105` `queries[i].length == 2` `0 <= li <= ri < nums.length`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "nums = [1,0,1], queries = [[0,2]]",12 "output": "true "13 },14 {15 "label": "Example 2",16 "input": "nums = [4,3,2,1], queries = [[1,3],[0,2]]",17 "output": "false "18 }19 ],20 "constraints": [21 "Select a subset of indices within the range [li, ri] in nums.",22 "Decrement the values at the selected indices by 1.",23 "For i = 0:\n\nSelect the subset of indices as [0, 2] and decrement the values at these indices by 1.\nThe array will become [0, 0, 0], which is a Zero Array.",24 "Select the subset of indices as [0, 2] and decrement the values at these indices by 1.",25 "The array will become [0, 0, 0], which is a Zero Array.",26 "Select the subset of indices as [0, 2] and decrement the values at these indices by 1.",27 "The array will become [0, 0, 0], which is a Zero Array.",28 "For i = 0:\n\nSelect the subset of indices as [1, 2, 3] and decrement the values at these indices by 1.\nThe array will become [4, 2, 1, 0].",29 "Select the subset of indices as [1, 2, 3] and decrement the values at these indices by 1.",30 "The array will become [4, 2, 1, 0].",31 "For i = 1:\n\nSelect the subset of indices as [0, 1, 2] and decrement the values at these indices by 1.\nThe array will become [3, 1, 0, 0], which is not a Zero Array.",32 "Select the subset of indices as [0, 1, 2] and decrement the values at these indices by 1.",33 "The array will become [3, 1, 0, 0], which is not a Zero Array.",34 "Select the subset of indices as [1, 2, 3] and decrement the values at these indices by 1.",35 "The array will become [4, 2, 1, 0].",36 "Select the subset of indices as [0, 1, 2] and decrement the values at these indices by 1.",37 "The array will become [3, 1, 0, 0], which is not a Zero Array.",38 "1 <= nums.length <= 105",39 "0 <= nums[i] <= 105",40 "1 <= queries.length <= 105",41 "queries[i].length == 2",42 "0 <= li <= ri < nums.length"43 ],44 "python_template": "class Solution(object):\n def isZeroArray(self, nums, queries):\n \"\"\"\n :type nums: List[int]\n :type queries: List[List[int]]\n :rtype: bool\n \"\"\"\n ",45 "java_template": "class Solution {\n public boolean isZeroArray(int[] nums, int[][] queries) {\n \n }\n}",46 "metadata": {47 "func_name": "isZeroArray"48 }49}