Ad
  • Default User Avatar

    The solution is optimal cause solution is always O(n) cause you have to iterate the whole array in every case for checking each value if it is string or int.

    This solutions is actually better than type checking each value cause the 'int' function already does a type check, in the case the argument is an int, it just return itself whithout doing any operation.

    Actually your solution is worse cause you are doing 2 type checkings instead of one, you are using try/catch in a loop wich is terrible slow, you are usign an extra array that consumes more memory which is not necesary, you are iterating the extra array making '2n + C' operations instead the 'n + C' from the best solution...

  • Default User Avatar

    Would you please give example entrie that are not in the test?

  • Default User Avatar

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

  • Custom User Avatar

    Print the input (the first string is what your function returned), it's a problem with your code. From those strings it seems you're grabbing the first number of the string, removing all numbers of it, adding 1 to the number you grabbed it and appending that to the end.

  • 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