12/11 Anybody know how StringBuffer.reverse() works? How would I do
that in O(n) time? --doesn't have a decompiler
\_ for(i=0;i<length of string; i++) {
newstring[i] = oldstring[length of string - i];
}
there, it's reversed. if youwant the original string copied
over, add:
for(i=0;i<length of string; i++) {
oldstring[i] = newstring[i];
}
That is an O(n) operation. You could claim it is an O(2n)
operation also, but only a fool would nitpick that. And
by the way, you are as dumb as a stone for having to ask.
\_ Informative and insulting in one response! Great work.
-geordan
\_ Should be "newstring[i] = oldstring[length of string - 1 - i];".
\_ Yeah. But you should have left it as an
exercise for the OP.
\_ FYI, Java source is always available to be downloaded; you don't
need a decompiler. |