Tap here to switch tabs
Problem
Submissions

Problem: Left and Right Sum Differences

med
30 min
Try to solve the Left and Right Sum Differences problem.

Statement

Given a 00 indexed integer array nums, determine an array answer of the same length such that:

answer[i] = |leftSum[i] - rightSum[i]|

Where:

  • leftSum[i] represents the sum of elements located to the left of index i in nums. If no elements exist to the left, leftSum[i] = 0.

  • rightSum[i] represents the sum of elements located to the right of index i in nums. If no elements exist to the right, rightSum[i] = 0.

Return the array answer.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Left and Right Sum Differences

med
30 min
Try to solve the Left and Right Sum Differences problem.

Statement

Given a 00 indexed integer array nums, determine an array answer of the same length such that:

answer[i] = |leftSum[i] - rightSum[i]|

Where:

  • leftSum[i] represents the sum of elements located to the left of index i in nums. If no elements exist to the left, leftSum[i] = 0.

  • rightSum[i] represents the sum of elements located to the right of index i in nums. If no elements exist to the right, rightSum[i] = 0.

Return the array answer.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤105\leq 10^5