First and third methods are extremely slow comparing to the second one.
Dmitry Korolev
21

Dmitry Korolev

I’m still a bit new to algorithms but why does this solution work faster — the 2nd method of the article calls one line of code during a for-loop that iterates [length of the string] times whereas your solution calls two lines of code in a for-loop that iterates [half the string length] times. Doesn’t that end up being the same amount of calls?

Like what you read? Give Ali Rehmatullah a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.