Ad
  • Default User Avatar

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

  • Custom User Avatar

    .split return strings and that coerces them into numbers.

    Granted, that's a weird way to do it, but it's not pointless. At all. If you try to remove that part, it wouldn't work.

  • Custom User Avatar

    This solution is bad. It is not about complexity, it is about memory usage. There is O(n) additional memory.

  • Default User Avatar

    Your solution loops through twice as well... What's the point of nitpicking time complexity when you are doing the same thing? Your else also doesn't need to find anything. You already have it in evenValues[0]. Even with that optimization, your worst case is still n^3 for an array length of 3 and n^2 for other cases.

    At least come up with a performant solution without unnecessary things before complaining that other people's solutions are "unnecessary and not performant".