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

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?

Show your support

Clapping shows how much you appreciated Ali Rehmatullah’s story.