Ad
  • Custom User Avatar

    Thanks for the help, turns out that while loop was the issue. I replaced it with a for loop instead and it solved the problem. No idea why I didn't use a for loop in the first place instead of beating my brain trying to figure out why my while loop wouldn't be exiting correctly.

  • Custom User Avatar

    I did not analyze your code deeply, but after a quick test with it, I fear your while loop on line 20 sometimes never ends (on some tests it reaches over 1000 iterations).

  • Custom User Avatar

    Tests are ok in Python, though they could be enhanced to return an explicit message rather than a raw error. The problem comes from your solution, that does not match the expected result, so some verification fails.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    5 is not a peak, the next value is greater.

    shouldn't potential a peak value be greater than last and first el in order to actually be a peak?

    No, being a peak (or local maxima) depends on the surrounding values.

  • Custom User Avatar

    ok. Thank you
    But what about 5 than?

    Also, if last and first elt-s should not be considered as peaks which is clear, shouldn't potential a peak value be greater than last and first el in order to actually be a peak?

  • Custom User Avatar

    Sorry for the late reply, your code is wrong, it's giving false positives on things that aren't plateaus. Print the input and you'll see it.

  • Custom User Avatar

    The first and last elements of the array will not be considered as peaks (in the context of a mathematical function, we don't know what is after and before and therefore, we don't know if it is a peak or not).

    3 is the only peak there. Use Question label next time.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution