in Java:

StringBuffer.reverse()

On Wed, May 1, 2013 at 9:08 PM, Sasha Pachev <[email protected]> wrote:
> First, let's say thanks to Matt for providing more employment
> opportunities for us. We are good at the technical aspect, but most of
> us are not so good at business.  We need to be thankful for the people
> that are good at business and remember that we need them as much as
> they need us. Perhaps we need them even more, because without us they
> would find another business avenue, but without thriving businesses
> our skills would not be worth much.
>
> Matt - did a guy with 10+ years of C experience seriously could not
> reverse a string, and you've met more than one? Was he bad at
> interviewing, did you try putting him in the corner with a text editor
> and a compiler to see if he could do it?
>
> Let me see if I can do it while thinking in e-mail mode:
>
> int str_rev(char* s)
> {
>    char* s_end;
>    char tmp;
>
>    if (!s) return -1;
>
>    s_end = s + strlen(s) - 1;
>
>    for (; s < s_end; s++, s_end--)
>    {
>       tmp = *s;
>       *s = *s_end;
>       *s_end = tmp;
>    }
>
>    return 0;
> }
>
> Ok, for a fun challenge, assuming the above actually compiles and runs
> without a bug, can somebody make it go faster and prove that it is
> indeed faster with a benchmark? Let's say that we compile the above
> with -O3 and you get to compile your code with -O3 as well.
>
> Now for a really fun challenge, can you make a Java version that is
> faster than the above and prove that it is? BTW, I do not know how.
>
> --
> Sasha Pachev
>
> Fast Running Blog.
> http://fastrunningblog.com
> Run. Blog. Improve. Repeat.
>
> /*
> PLUG: http://plug.org, #utah on irc.freenode.net
> Unsubscribe: http://plug.org/mailman/options/plug
> Don't fear the penguin.
> */

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to