Originally posted by Graeme Byers: Any one tried this ?
I know it exists, and it could be used for this problem quite well indeed.
However, from a performance point, I'd say that just iterating through half the string will be more efficient than all other solutions. Please note that the recursive method basically does the same, so it's just as efficient*. Reversing the string requires a) iterating over the string once (although StringBuilder.reverse swaps elements, so again half the string in operations), then b) iterating over both strings again (for the equals test). And to make it worse, you need an extra object.
Sure, nearly all solutions shown are still O(n), but the difference between 10 minutes and 5 minutes (for extremely long strings ) is still worth the trouble.
* Well, perhaps for an increasing stack - every call will put the arguments and local variables on the stack. A loop won't. [ August 14, 2008: Message edited by: Rob Prime ]