Skip to content

devDoubleH/find_pivot_index

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Qwasar Silicon Valley

find pivot index from array of integers

Write a function that returns the pivot index of a given array of integers.

The pivot index is where the sum of the numbers on the left equal the sum of the numbers on the right.

If no such index exists, return -1.

If there are multiple pivot indexes, return the left-most pivot index.

Example:

Input: [1, 7, 3, 6, 5, 6]

Output: 3

Explanation:

The sum of the numbers to the left of index 3 (nums[3] = 6) is equal to the sum of numbers to the right of index 3.

Also, 3 is the first index where this occurs.

Input: [1, 2, 3]

Output: -1

Explanation:

There is no index that satisfies the conditions in the problem statement.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published