Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
left-and-right-sum-differences.json31 linesDownload Raw Back to root
1{2  "id": 2714,3  "name": "left-and-right-sum-differences",4  "difficulty": "Easy",5  "link": "https://leetcode.com/problems/left-and-right-sum-differences/",6  "date": "2023-02-19",7  "task_description": "You are given a **0-indexed** integer array `nums` of size `n`. Define two arrays `leftSum` and `rightSum` where: `leftSum[i]` is the sum of elements to the left of the index `i` in the array `nums`. If there is no such element, `leftSum[i] = 0`. `rightSum[i]` is the sum of elements to the right of the index `i` in the array `nums`. If there is no such element, `rightSum[i] = 0`. Return an integer array `answer` of size `n` where `answer[i] = |leftSum[i] - rightSum[i]|`. **Example 1:** ``` **Input:** nums = [10,4,8,3] **Output:** [15,1,11,22] **Explanation:** The array leftSum is [0,10,14,22] and the array rightSum is [15,11,3,0]. The array answer is [|0 - 15|,|10 - 11|,|14 - 3|,|22 - 0|] = [15,1,11,22]. ``` **Example 2:** ``` **Input:** nums = [1] **Output:** [0] **Explanation:** The array leftSum is [0] and the array rightSum is [0]. The array answer is [|0 - 0|] = [0]. ``` **Constraints:** `1 <= nums.length <= 1000` `1 <= nums[i] <= 105`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [10,4,8,3]",12      "output": "[15,1,11,22] "13    },14    {15      "label": "Example 2",16      "input": "nums = [1]",17      "output": "[0] "18    }19  ],20  "constraints": [21    "leftSum[i] is the sum of elements to the left of the index i in the array nums. If there is no such element, leftSum[i] = 0.",22    "rightSum[i] is the sum of elements to the right of the index i in the array nums. If there is no such element, rightSum[i] = 0.",23    "1 <= nums.length <= 1000",24    "1 <= nums[i] <= 105"25  ],26  "python_template": "class Solution(object):\n    def leftRightDifference(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: List[int]\n        \"\"\"\n        ",27  "java_template": "class Solution {\n    public int[] leftRightDifference(int[] nums) {\n        \n    }\n}",28  "metadata": {29    "func_name": "leftRightDifference"30  }31}