Ad
  • Custom User Avatar

    You can print the input and analyze it yourself. And IIRC the description is clear about the specifications.

  • Custom User Avatar

    I was also stumped, but re-read instructions and it's probably related to:

    Also, beware of plateaus !!! [1, 2, 2, 2, 1] has a peak while [1, 2, 2, 2, 3] does not.

    So imagine you are working with an arr like [1, 2, 2, 2, 3, 3], where the second to last number (the first 3) is giving you a false positive.

    Edit: and also imagine if you are working with double plateaus such as [1, 2, 2, 3, 3, 1]. In this case, the peak should be the first 3, but it's possible that the first 2 is giving you a false positive resulting in 2 peaks, when there should only be 1 in this case.

    Hopefully final edit: I created a test scenario which your code might not pass according to your errors: [1,1,2,2,3,5,5,5,3,3,3,1,2,3]. There should only be 1 peak, but your code might give 2. Just passed this, so hopefully this helps.

  • Custom User Avatar

    Yes. First take every 2nd char. And then the "other chars" are the chars, that are not every 2nd char. :-)

  • Custom User Avatar

    Take every 2nd char from the string. Then the other chars. Do this n times! Whats wrong!?