#include <iostream>
#include <cstring>
#include <limits>
int main()
{
constexpr char cstr[] = "introduction";
// initialize an array to hold the count of occurrances
int counts[ std::numeric_limits<unsigned char>::max() ] = {0} ;
// populate the counts
for( unsigned char u : cstr ) ++counts[u] ;
// find the first char for which count is equal to 1
for( unsigned char u : cstr ) if( counts[u] == 1 && u != 0 )
{
std::cout << "first non-repeating char is '" << char(u) << "'\n" ;
break ;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGxpbWl0cz4KCmludCBtYWluKCkKewogICAgY29uc3RleHByIGNoYXIgY3N0cltdID0gImludHJvZHVjdGlvbiI7CgogICAgLy8gaW5pdGlhbGl6ZSBhbiBhcnJheSB0byBob2xkIHRoZSBjb3VudCBvZiBvY2N1cnJhbmNlcwogICAgaW50IGNvdW50c1sgc3RkOjpudW1lcmljX2xpbWl0czx1bnNpZ25lZCBjaGFyPjo6bWF4KCkgXSA9IHswfSA7CgogICAgLy8gcG9wdWxhdGUgdGhlIGNvdW50cwogICAgZm9yKCB1bnNpZ25lZCBjaGFyIHUgOiBjc3RyICkgKytjb3VudHNbdV0gOwoKICAgIC8vIGZpbmQgdGhlIGZpcnN0IGNoYXIgZm9yIHdoaWNoIGNvdW50IGlzIGVxdWFsIHRvIDEKICAgIGZvciggdW5zaWduZWQgY2hhciB1IDogY3N0ciApIGlmKCBjb3VudHNbdV0gPT0gMSAmJiB1ICE9IDAgKQogICAgewogICAgICAgIHN0ZDo6Y291dCA8PCAiZmlyc3Qgbm9uLXJlcGVhdGluZyBjaGFyIGlzICciIDw8IGNoYXIodSkgPDwgIidcbiIgOwogICAgICAgIGJyZWFrIDsKICAgIH0KfQo=