slippy, do a barrel roll
Stumbled upon this in a stackoverflow answer. Naive C programmers write this sort of loop:
for (int cnt=0; cnt < strlen(s) ; cnt++) {
/* some code */
}
That’s logically an O(n2) algorithm because of the implementation of strlen().
Even though I know strlen
is implemented very efficiently, let’s not do this.