Ad
  • Custom User Avatar

    As Chrono said, I think you misread the instructions. If you still don't understand why it isn't 1, I can go into more detail. Just let me know.

  • Custom User Avatar

    How is 1 equal to 3 + 4 + 3 + 2 + 1? There's no mistake in the instructions. Read them again:

    You are going to be given an array of integers. Your job is to take that 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.

  • Custom User Avatar

    I found a mistake in the detailing of the problem, it specifies that whenever multiple solutions are present, it should return the lowest index, even in the test example {[1,2,3,4,3,2,1]} it says its expecting a 3 when the lowest index that satifies the solution is 1 ... puzzling

  • Custom User Avatar

    It is indeed somewhat inefficient and potentially return an error, given p0 = 100, percent = 2, aug = 10, p = 100 (I know, evil)
    it would return 1 year, while the correct answer would be 0.
    To solve it, initialize years = 0, get rid of the initial pCalc (that already assumes it year 1), and place it all inside the loop :)