[Solved] working of these two lines of code in the program [closed]


The total variable will contain the number of unique characters in the array str.

This happens because you increment the count(total+=!used[str[i]-'a']) only if you haven’t already marked the character as visited. If you incremented it, you mark it as such in the next line (used[str[i]-'a']=1) so that you wont count it again.

The notation str[i]-'a' is used to shift the ascii values of the characters from 0 to 25 (instead of 97 to 122) so that you can spare some space in the array.

9

solved working of these two lines of code in the program [closed]