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:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Python program to check if given string is pangram
- Check if a string can be converted to another string by replacing vowels and consonants
- Check if one string can be converted to another
- Check if one string can be converted to other using given operation
- 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 be formed from another string by at most X circular clockwise shifts
- Check if any permutation of string is a K times repeated string
- Check if a string can be obtained by rotating another string d places
- Queries to check if string B exists as substring in string A
- Check if a string can be obtained by rotating another string 2 places
- Check if a string can become empty by recursively deleting a given sub-string
- Check if left and right shift of any string results into given string
- Check if a string is a scrambled form of another string
- Check if a string contains a palindromic sub-string of even length
- Check if a string can be repeated to make another string
- Check if a given string is a Reverse Bitonic String or not
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.