Arrays2 Flashcards

1
Q

Your job is to take an array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no index that would make this happen, return -1.

Let’s say you are given the array {1,2,3,4,3,2,1}:
Your function will return the index 3, because at the 3rd position of the array, the sum of left side of the index ({1,2,3}) and the sum of the right side of the index ({3,2,1}) both equal 6.

A
function findEvenIndex(arr)
{
  //Code goes here!
  for (var i = 0; i
How well did you know this?
1
Not at all
2
3
4
5
Perfectly