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)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count and Print the alphabets having ASCII value not in the range [l, r]
- Count and Print the alphabets having ASCII value 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
- Check if count of Alphabets and count of Numbers are equal in the given String
- 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
- For each lowercase English alphabet find the count of strings having these alphabets
- Count positions such that all elements before it are greater
- Count number of substrings with numeric value greater than X
- Count of substrings whose Decimal equivalent is greater than or equal to K
- 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
- Count substring of Binary string such that each character belongs to a palindrome of size greater than 1
- ascii() in Python
- Program to generate random alphabets
- Print the Alphabets A to Z in Star Pattern
- Remove all characters other than alphabets from string
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.