Ad
  • Default User Avatar

    I had to comment on this as it's an incredibly inefficient solution for one simple reason.
    You are calling strlen(walk) twice inside the loop and when you call strlen(walk) you are basically iterating over whole string.
    One small change is required to change time complecity of this algorithm from O(2n^2) to O(2n):

    • Save result of strlen(walk) to variable and replace both occurances of strlen(walk) in your code with this variable.

    Aside from that there is completely no reason to call 'if (strlen(walk) != 10) return false;' inside the loop. Just move it before the loop.