1.
bool Palindrome( const apstring & A )
{
for( int i = 0; i < A.length( ) / 2; i++ )
{
if( A[ i ] != A[ A.length( ) - ( i + 1 ) )
return false;
}
return true;
}
2.
bool Equals( const apvector & v1, const apvector & v2 )
{
if( v1.length( ) != v2.length( ) )
return false;
for( int i = 0; i < v1.length( ); i++ )
{
if( v1[ i ] != v2[ i ] )
return false;
}
return true;
}
3.
apvector WithoutDuplicates( const apvector & v )
{
apvector copy = v;
apvector answer;
int itemsCopied = 1;
if( v.length( ) == 0 )
return copy;
sort( copy );
answer.resize( copy.length( ) );
answer[ 0 ] = copy[ 0 ];
for( int i = 1; i < copy.length( ); i++ )
{
if( copy[ i ] != copy[ i - 1 ] )
{
answer[ itemsCopied ] = copy[ i ];
itemsCopied++;
}
}
answer.resize( itemsCopied );
return answer;
}