Tap here to switch tabs
Problem
Submissions

Problem: Left and Right Sum Differences

Left and Right Sum Differences asks you to build an array where each value is the absolute difference between the sums of all elements to its left and right.

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

Left and Right Sum Differences asks you to build an array where each value is the absolute difference between the sums of all elements to its left and right.

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