Check if string has unique characters
algorithm, c++
Solution
You can use `toupper` or `tolower` on all characters to make sure that you catch duplicates that are different only in their case:
int val = toupper(str[i]); // tolower would be fine as well
As a side note, a canonical way of assigning `true` to a `bool` in C++ is
arr[val] = true; // rather than arr[val] = 1
although both ways work fine.
Problem
I know how to check if the string has unique characters , but i want to to display NOT UNIQUE even if they are of different cases eg - My algorithm string = "dhAra" => UNIQUE What i think would be better is that it displays NOT UNIQUE because it has 'a' twice ``` #include<iostream> int main() { string str = "dhAra"; bool arr[128] = {0}; for (unsigned int i = 0; i < str.length() ; i++) { int val = str[i]; //i think something needs to change here cout << val << endl; if(arr[val]) { cout << " not unique" ; return 0; } else { arr[val] = 1;} } cout << "unique" ; return 0 ; } ```