nfactorial_
Check me out on the web at Welcome to n!'s Domain or at my blog.
Software Engineer from the UK.
| Forum | Thread | Replies | Latest activity |
|---|---|---|---|
| Tech Off | gdi+ hardware acceleration | 4 | Oct 08, 2004 at 6:51 AM |
Gary Daniels and Evan Goldring - Mock whiteboard problem
Sep 11, 2004 at 3:53 PMThe result I would have come up with would have been something similar to:
bool IsPanlindrome( TCHAR *pszString )
{
if ( NULL == pszString )
return false;
const int length = lstrlen( pszString );
const int repeat = length / 2;
for ( int loop = 0; loop < repeat; ++loop )
{
if ( pszString[ loop ] != pszString[ length - 1 - loop ] )
return false;
}
return ( 0 != length );
}
I say similar, because I would probably have been very nervous so it may not have been exactly the same. I also think I wouldn't have written as much pseudo code as in the video, as the simplicity of the question coupled with my nervousness may have had me thinking 'he just wants me to write the code'.
I would have pointed out I was dividing the length by two because the integer arithmetic would simply discard the central character for odd length strings.
n!