Find Pivot Index

Given an array of integers nums, find a pivot index where the sum of numbers to the left equals the sum to the right.

Input Format

nums = array of integers

Output Format

Index of pivot or -1 if none

Constraints

  • 1 <= nums.length <= 10^4; -1000 <= nums[i] <= 1000

Examples

Example 1:

Input:

nums = [1,7,3,6,5,6]

Output:

3

Explanation:

Index 3 has left sum 11 and right sum 11.

Loading...
Find Pivot Index - Arrays DSA Problem