Topic: Strings
Questions Successfully Completed: 1
1) Panagram Checking | Easy |
Question
Input: S = Bawds jog, flick quartz, vex nymph Output: 1 Explanation: In the given input, there are all the letters of the English alphabet. Hence, the output is 1.
// A-Z ---> 65 to 90 // a-z ----> 97-122
public static boolean checkPangram (String str) {
String str1 = str.toLowerCase(Locale.ROOT);
int[] CharHash = new int[125];
char[] c = str1.toCharArray();
boolean flag = false;
//System.out.println(); // ASCII of B is 66, ASCII of 0 is 48, so result is 18
for (int i = 0; i < c.length; i++) { // O(N)
int ascii_letter = c[i] - '0' + '0';
CharHash[ascii_letter]++;
}
for(int l=97;l<=122;l++){
if(CharHash[l]>=1){
flag = true;
}
else{
flag = false;
break;
}
}
return flag;
}
Thank you for reading :)