




Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
A pivot point splits the array into equal prefix and suffix. If no change is made to the array, the goal is to find the number of pivot p such that prefix[p-1] == suffix[p].
Consider how prefix and suffix will change when we change a number nums[i] to k.
When sweeping through each element, can you find the total number of pivots where the difference of prefix and suffix happens to equal to the changes of k-nums[i].