Given a string str, the task is to count the number of alphabets having ascii values not in the range [l, r].
Input: str = "geeksforgeeks", l = 102, r = 111 Output: Count = 7 Characters - e, s, r have ascii values not in the range [102, 111]. Input: str = "GeEkS", l = 80, r = 111 Output: Count = 2
Approach: Start traversing the string and check if the current character has ASCII value less than equal to r and greater than equal to l. If no then increment the count and print that element.
Below is the implementation of above approach:
Characters with ASCII values not in the range [l, r] in the given string are: e s r and their count is 7
Time Complexity : O(n) where n is the length of string.
- Count and Print the alphabets having ASCII value in the range [l, r]
- Count of alphabets having ASCII value less than and greater than k
- Check if a string contains only alphabets in Java using ASCII values
- Program to print ASCII Value of a character
- Print given sentence into its equivalent ASCII form
- Print each word in a sentence with their corresponding average of ASCII values
- 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 the number of words having sum of ASCII values less than and greater than k
- Program to print all palindromes in a given range
- Count Unary Numbers in a Range
- Queries to print the character that occurs the maximum number of times in a given range
- Count of Palindromic substrings in an Index range
- Count number of indices such that s[i] = s[i+1] : Range queries
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.