Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Gary Daniels and Evan Goldring - Mock whiteboard problem
Aug 25, 2004 at 6:49 PM// Quickie C++ - worked the first time.
// Easier than the whiteboard question I got in
// my MSFT interview.
//
// Oh yeah, this version ignores spaces just
// for grins.
//
#include <cassert>
template <
typename RandIt,
typename CharT,
CharT space
>
bool IsPalindrome(RandIt start, RandIt end)
{
end--;
do
{
while (space == *start)
start++;
while (space == *end)
end--;
if (end < start)
return false;
if (*start != *end)
return false;
start++;
end--;
} while (start<end);
return true;
}
bool IsPalindrome(const char* str)
{
assert(str);
return IsPalindrome<const char*,char,' '>(
str,
str+strlen(str)
);
}