Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
For each index i, maintain two variables leftSum and rightSum.
Iterate on the range j: [0 … i - 1] and add nums[j] to the leftSum and similarly iterate on the range j: [i + 1 … nums.length - 1] and add nums[j] to the rightSum.