Ad
  • Default User Avatar

    Finding thepeaks is not difficult, but your wanted solution with a Map and List is confusing, why not use a Map and put a position and a peakheight together?

  • Default User Avatar

    Thanks, found my mistake. i need to make it better because its too slow

  • Default User Avatar
    1. your code is not efficient enough
    2. very carefully (re)read the entire description
  • Default User Avatar

    it keeps saying timed out. -_- i am new can someone help me

  • Default User Avatar

    sorry, i am quite new and now that i saw the solutions i get it.
    I would still leave the comment up, if others run in the same issue.

    thanks

  • Custom User Avatar

    Read the description:

    NOTE on performance: There are no fancy optimizations required, but still the most trivial solutions might time out. Numbers go up to 2^31 ( or similar, depending on language ). Looping all the way up to n, or n/2, will be too slow.

    And that's what your code does, so, no wonder it will fail.

  • Default User Avatar

    The kata works fine in Java (your language). Your code timing out is not a kata issue. You need to write a more efficient algorithm.

  • Default User Avatar

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