Ad
  • Custom User Avatar

    Your solution has worse time complexity than needed. Your function is performing more operations than needed and so consumes more time.

  • Custom User Avatar

    You have loops inside loops (yes, includes, indexOf and splice have loops inside), that won't work with long strings.

  • Custom User Avatar

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

  • Custom User Avatar

    You can print stuff to stdout and they will show up in the test output as 'log' boxes.

    You might want to print out the lengths of the input strings to see if the timeout was caused by your algorithms not being able to handle such large inputs.

    If inputs of comparable lengths work without a problem when you try then it might have hit a infinite/very long loop condition in your algorithm. Either print and grab the input if it's not too long to print, or try generating inputs yourself.

    In any case, the 'passing all tests' is inaccurate in the case of a timeout, because the rest of the tests are not even run.