The program finds the first non repeating character in a character array, array contains only small case letters.  #include<iostream>#include<cstring>using namespace std;int main(){char a2z[26]={0};//Hashchar input[100] = abcbbbcdegh;//sample input, only small case english alphabetsint n = strlen(input);for(int i=0; i<n; ++i){    if( a2z[  input[i]-97 ]<0 )    {         //do nothing, this character has already repeated    }    else if( a2z[  input[i]-97 ]==0 )    {        a2z[ input[i]-97 ] = i+1; //character encoutered first time    }    else    {        a2z[ input[i]-97 ] = -(i+1); //repeating character    }}int minAt=n+1;for(int i=0; i<26; ++i) //finding first non-negative character in the Hash{    if( (a2z[i]>0) && (a2z[i]<minAt) )    {        minAt=a2z[i];    }}if( minAt == n+1 )    cout<<\n\n no unique character;else    cout<<\n\nFirst unique character is <<input[minAt-1]<< at position <<minAt-1<<endl; }  output ::  First unique character is a at position 0here, i have taken an character array (i.e. a2z) of 26 characters initialized with zero, using it as Hash. if a2z[i] is zero means ith character (of English alphabet) has not encountered till now, postive value of a2z[i] denotes ith character has been encountered only once at position a2z[i]-1, and negative values shows it has repeated.pls review this code.
Searching first non repeating character
c++;array
As far as this program goes, there's not very many non-opinion improvements possible.There are, however, a few correctness/(micro) optimization points:char a2z[26]A char is likely not big enough.a2z[ input[i]-97 ] = i+1;a2z[ input[i]-97 ] = -(i+1);i = 0 ... strlen(input)-1 therefore min(i) = 0 and max(i) = strlen(input).A signed char, c, can be: -128 <= c <= 127, therefore, your implementation is limited to strlen(input) <= 127.Implicit Double LoopingTypically strlen() is implemented vaguely like:size_t strlen(const char* str){    size_t len = 0;    while (str[len] != 0) {        ++len;    }    return len;}Thus your program is looping over the string twice.You could change your loop to basically embed the strlen in your code:for(int i=0, const char* c = input; c != 0; ++i, ++c) {That could be written a bit more cleanly, but hopefully it gets the point across.(It also is probably not a very meaningful optimization.  It likely would have equal, or depending on exactly how the loop is done, potentially worse performance.  Just something to consider if you're trying to micro-optimize.)Style oddities (blatant opinion with no backing)These are a few items that are completely arbitrary in terms of correctness (basically all personal preferences):It's valid, but for the sake of explicitness, I prefer to use thelong form of main() and always include a return.I also prefer to always use braces around the expressions for if and else statements.  It's entirely a personal preference, but I've found that it tends to produces clearer, less error prone code#include<iostream> I don't actually know if it's valid to not have a space between include and the file.  Either way, I very rarely see it written like that, and it looks a bit odd.a2z[ input[i]-97 ] looks a bit odd to me.char input[100] = abcbbbcdegh; could be const char input[] = abcbbbcdegh;