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:
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.
- Check if a string can be converted to another string by replacing vowels and consonants
- Python program to check if given string is pangram
- C++ program to check whether a String is a Pangram or not
- Check if a given string is Pangram in Java
- Check if one string can be converted to another
- Check if one string can be converted to other using given operation
- Check if a string can be converted to another by swapping of adjacent characters of given type
- Check if a given string can be converted to another by given possible swaps
- Check whether str1 can be converted to str2 with the given operations
- Missing characters to make a string Pangram
- Count the nodes of the tree which make a pangram when concatenated with the sub-tree nodes
- Pangram Checking
- Using Set() in Python Pangram Checking
- Minimum changes required to make first string substring of second string
- Sort an Array alphabetically when each number is converted into words
- Minimum changes required such that the string satisfies the given condition
- Minimum flips required to form given binary string where every flip changes all bits to its right as well
- Minimum changes to a string to make all substrings distinct
- 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
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.