Ad
  • Custom User Avatar

    There are 2 problems I see with your current code:

    • You're calling strlen() on each loop iteration, causing a timeout.
    • You're using char* (aka string) to count things: that's definitely not the right type for the job.
  • Custom User Avatar

    O(len(s1+s2)) is an expectedc complexity for this problem, and you seem to get this part right.

    I just tried your solution and I get no timeout, just incorrect answers in large tests?

  • Custom User Avatar

    My C code runs with a time complexity of O(s1.length() + s2.length()) for its worst case and O(s2.length() * 2) in the best case but i still get a timeout. What might be cause for this (I have one for loop iterating over the first string and one itereating over the second string they are not nested. Possible memory leaks have been fixed)