You are given an integer array nums of length n.
A partition is defined as an index i where 0 <= i < n - 1, splitting the array into two non-empty subarrays such that:
Return the number of partitions where the difference between the sum of the left and right subarrays is even.
Input: nums = [1,2,2]
Output: 0
Explanation:
No partition results in an even sum difference.
Example 3
Input: nums = [2,4,6,8]
Output: 3
Explanation:
All partitions result in an even sum difference.
Constraints
2 <= n == nums.length <= 100
1 <= nums[i] <= 100
3432. Count Partitions with Even Sum Difference
Easy
10 Points
Array
Math
Prefix Sum
You are given an integer array nums of length n.
A partition is defined as an index i where 0 <= i < n - 1, splitting the array into two non-empty subarrays such that:
Return the number of partitions where the difference between the sum of the left and right subarrays is even.