Given a String str containing only lowercase English alphabets and an integer K. The task is to check that whether the string can be converted to a Pangram by performing at most K changes. In one change we can remove any existing character and add a new character.
Pangram: A pangram is a sentence containing every letter in the English Alphabet.
Note: Given that length of string is greater than 26 always and in one operation we have to remove an existing element to add a new element.
Input : str = "qwqqwqeqqwdsdadsdasadsfsdsdsdasasas" K = 4 Output : False Explanation : Making just 4 modifications in this string, it can't be changed to a pangram. Input : str = "qwqqwqeqqwdsdadsdasadsfsdsdsdasasas" K = 24 Output : True Explanation : By making 19 modifications in the string, it can be changed to a pangram.
- Traverse the string character by character to keep track of all the characters present in the array using a boolean visit array.
- Using a variable count, traverse the visit array to keep count of the missing characters.
- If count value is less than or equal to K, print True.
- Else print False.
Below is the implementation of above approach:
- Python program to check if given string is pangram
- Check if a string can be converted to another string by replacing vowels and consonants
- Missing characters to make a string Pangram
- Check whether str1 can be converted to str2 with the given operations
- Pangram Checking
- Using Set() in Python Pangram Checking
- String slicing in Python to check if a string can become empty by recursive deletion
- Check if a string can become empty by recursively deleting a given sub-string
- Check if a string can be obtained by rotating another string 2 places
- Queries to check if string B exists as substring in string A
- Check if a string can be obtained by rotating another string d places
- Check if a string can be repeated to make another string
- Check whether second string can be formed from characters of first string
- Check if a string contains a palindromic sub-string of even length
- Count the nodes of the tree which make a pangram when concatenated with the sub-tree nodes
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.