Given a string, the task is to count the number of alphabets having ASCII value less than and greater than or equal to a given integer k.
Input: str = "GeeksForGeeks", k = 90 Output: 3, 10 G, F, G have ascii values less than 90. e, e, k, s, o, r, e, e, k, s have ascii values greater than or equal to 90 Input: str = "geeksforgeeks", k = 90 Output: 0, 13
Approach: Start traversing the string and check if the current character has ASCII value less than k. If yes then increment the count.
So, Remaining characters will have ASCII values greater than or equal to k. So, print len_of_String – count for characters with ASCII values greater than or equal to k.
Below is the implementation of the above approach:
Characters with ASCII values less than K are 3 Characters with ASCII values greater than or equal to K are 10
Time Complexity: O(N)
- Count and Print the alphabets having ASCII value in the range [l, r]
- Count and Print the alphabets having ASCII value not in the range [l, r]
- Count the number of words having sum of ASCII values less than and greater than k
- Check if a string contains only alphabets in Java using ASCII values
- Sub-strings having exactly k characters that have ASCII value greater than p
- Count of character pairs at same distance as in English alphabets
- Count pairs of characters in a string whose ASCII value difference is K
- Count characters in a string whose ASCII values are prime
- Count number of substrings with numeric value greater than X
- Noble integers in an array (count of greater elements is equal to value)
- Count number of binary strings such that there is no substring of length greater than or equal to 3 with all 1's
- Program to generate random alphabets
- Remove all characters other than alphabets from string
- Remove consecutive alphabets which are in same case
- Program to display all alphabets from A to Z in uppercase and lowercase both
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.