![]() |
VOOZH | about |
Given a string S, the task is to count the number of camel case characters present in the given string.
The camel case character is defined as the number of uppercase characters in the given string.
Examples:
Input: S = "ckjkUUYII"
Output: 5
Explanation:
Camel case characters present are U, U, Y, I and I.Input: S = "abcd"
Output: 0
Approach: The given problem can be solved by traversing the given string S and count those characters whose ASCII value lies over the range [65, 91]. After checking for all the characters, print the total count obtained as the result.
Below is the implementation of the above approach:
5
Time Complexity: O(N)
Auxiliary Space: O(1)
Alternate Approach: The idea is to use the inbuilt library function isupper() to check whether the character is an uppercase letter or not. Follow the steps below to solve the problem:
Below is the implementation of the above approach:
5
Time Complexity: O(N)
Auxiliary Space: O(1)