Sherlock and The Beast

  • + 1 comment

    I didn't downvote since this is a perfectly fine answer, but are you sure string() isn't using a loop under the hood? The solutions using a while loop in these examples will only iterate twice at most, which is O(1). Solutions on this page are pretty much all O(n) because of the string multiplication loops which are the most expensive part of the function. Correct me if I'm mistaken!