https://github.com/markfchavez/pivot_ruby
https://github.com/markfchavez/pivot_ruby
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/markfchavez/pivot_ruby
- Owner: MarkFChavez
- Created: 2019-01-28T14:19:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-28T14:19:55.000Z (over 7 years ago)
- Last Synced: 2025-02-06T15:53:13.588Z (over 1 year ago)
- Language: Ruby
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Problem
Write a method that returns the "pivot" index of a list of integers. We
define the pivot index as the index where the sum of the numbers on the
left is equal to the sum of the numbers on the right. Given [1, 4, 6, 3, 2],
the method should return 2, since the sum of the numbers to the left of index
2 is equal to the sum of numbers to the right of index 2 (1 + 4 = 3 + 2).
If no such index exists, it should return -1. If there are multiple
pivots, you can return the left-most pivot.
You can write the method in any language. Make sure that the method:
• runs successfully
• handles all edge cases
• is as efficient as you can make it!
A successful answer will fulfill the above criteria.