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.
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 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
- Check if count of Alphabets and count of Numbers are equal in the given String
- Print the Alphabets A to Z in Star Pattern
- 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
- For each lowercase English alphabet find the count of strings having these alphabets
- Program to print all palindromes in a given range
- Queries to print the character that occurs the maximum number of times in a given range
- Count Unary Numbers in a Range
- Count number of indices such that s[i] = s[i+1] : Range queries
- Count of Numbers in Range where the number does not contain more than K non zero digits
- Count of Palindromic substrings in an Index range
- Count of numbers in a range that does not contain the digit M and which is divisible by M.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.