3 ms·
To paraphrase Don Knuth, "I have only proven it correct, I haven't tested it." To be fair, he says "likely to be" and results may vary between compilers. He al
by robert_tweed 12y ago
To paraphrase Don Knuth, "I have only proven it correct, I haven't tested it."
To be fair, he says "likely to be" and results may vary between compilers. He also makes reference to the speed penalty of calling strlen(), which isn't necessary with std:string because it stores the length. Even with more allocations, it's possible the C++ version runs faster. It should have a lower computational complexity, meaning it would be faster if the input strings were much longer than they are in this example.