Easy Accuracy: 17.86% Submissions: 3298 Points: 2

Given a string str and an integer K, find whether the string can be changed into a pangram after at most k operations. A pangram is a sentence containing every letter in the english alphabet. A single operation can be used to swap an existing alphabetic character with any other alphabetic character.

Example 1:

str = "the quick brown fox jumps over the lazy dog"
k = 0
Output: 1
Explanation: the sentence contains all 26 characters 
and is already a pangram. 

Example 2:

str = "aaaaaaaaaaaaaaaaaaaaaaaaaa"
k = 25
Output: 1
Explanation: The word contains 26 instances of 'a'.
Since only 25 operations are allowed. We can keep
1 instance and change all others to make str a pangram.

Your Task:  
You dont need to read input or print anything. Complete the function kPangram() which takes str and k as input parameters and returns a boolean value which denotes if pangram is possible or not.

Expected Time Complexity: O(N) where N is length of str.
Expected Auxiliary Space: O(1)  

1<= N <= 104
String may contain duplicate characters.
String can contain only lowercase alphabets or space.


We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.


Output Window