[Cpp]
# Include <stdio. h>
# Include <string. h>
# Include <assert. h>
Unsigned int hashTable [256];
Char queue [256];
Char solve (char * str)
{
Unsigned int I = 0;
Memset (hashTable, 0, sizeof (hashTable ));
Memset (queue, '0', sizeof (queue ));
Int index = 0;
For (I = 0; I <strlen (str); I ++)
{
Int loc = (int) str [I];
If (hashTable [loc] = 0)
{
Queue [index ++] = str [I];
HashTable [loc] = 1;
}
Else
{
HashTable [loc] + = 1;
}
}
For (I = 0; I <index; I ++)
{
Int loc = (int) queue [I];
If (hashTable [loc] = 1)
Return queue [I];
}
Return NULL;
}
Void testSize ()
{
// Differentiate sizeof from strlen
Char * s = "abcdefg ";
Printf ("% d \ n", sizeof (s), strlen (s); // 4 7
Char ss [] = "abcdefg ";
Printf ("% d \ n", sizeof (ss), strlen (ss); // 8 7
}
Void test ()
{
Char * str = "abaccdeff ";
Char c = solve (str );
Printf ("% c \ n", c );
}
Int main ()
{
TestSize ();
Test ();
Return 0;
}