Ad
  • 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 :)