2574. Left and Right Sum Differences
Easy
Given a 0-indexed integer array nums
, find a 0-indexed integer array answer
where:
answer.length == nums.length
.answer[i] = |leftSum[i] - rightSum[i]|
.
Where:
leftSum[i]
is the sum of elements to the left of the indexi
in the arraynums
. If there is no such element,leftSum[i] = 0
.rightSum[i]
is the sum of elements to the right of the indexi
in the arraynums
. If there is no such element,rightSum[i] = 0
.
Return the array answer
.
Example 1:
Example 2:
Constraints:
1 <= nums.length <= 1000
1 <= nums[i] <= 10^5
解題
Previous2500. Delete Greatest Value in Each RowNext2602. Minimum Operations to Make All Array Elements Equal
Last updated