Find Pivot Index
Given an integer array nums, return the leftmost pivot index, where the sum strictly to its left equals the sum strictly to its right. Return -1 when no pivot…
Given an integer array `nums`, return the leftmost pivot index, where the sum strictly to its left equals the sum strictly to its right. Return `-1` when no pivot exists.
- `1 <= nums.length <= 10^4` - `-10^6 <= nums[i] <= 10^6`
Example 1: input nums = [1,7,3,6,5,6]; output 3. The values on both sides of index 3 sum to 11.
Example 2: input nums = [1,2,3]; output -1. No index balances the two side sums.
Category: Arrays & Hashing. Topic: arrays. Difficulty: Easy. Patterns: prefix-sum.