Find Pivot Index

Easy · Arrays & Strings · about 10 minutes

Asked at Meta, Amazon, Google, Bloomberg, Microsoft.

Return the leftmost pivot index of nums: an index where the sum of the elements strictly to its left equals the sum strictly to its right (an empty side sums to 0). Return -1 if there is none.