Unique Character Count

Easy
0/40
3 upvotes

Problem statement

You are given a string str consisting of lowercase English alphabets. Your task is to determine and count the number of unique characters present in the string.


Detailed explanation ( Input/output format, Notes, Images )
Input Format:
The first line of input contains a single string str.


Output Format:
Print a single integer representing the total count of unique characters.


Note:
The string consists only of lowercase English letters ('a' through 'z').
Sample Input 1:
codingninjas


Sample Output 1:
9


Explanation for Sample 1:
The given string “codingninjas” contains 9 unique characters: ‘c’, ‘o’, ‘d’, ‘i’, ‘n’, ‘g’, ‘j’,'a','s'.


Sample Input 2:
madam


Sample Output 2:
3


Explanation for Sample 2:
The unique characters in "madam" are 'm', 'a', and 'd'. The total count is 3.


Expected Time Complexity:
The expected time complexity is O(N), where N is the length of the string.


Constraints:
1 <= N <= 10^5
`str` consists of lowercase English letters ('a'-'z').

Time limit: 1 sec
Approaches (1)
Unique Character Count
Time Complexity
Space Complexity
Code Solution
(100% EXP penalty)
Unique Character Count
Full screen
Console