Write a Java program to check if the sentence or string is Pangram or not.

A pangram or holoalphabetic sentence is a sentence using every letter of a given alphabet at least once. The best-known English pangram is “The quick brown fox jumps over the lazy dog“.

So we need to check whether the given string contains all English alphabets or not.

Example:

The plan is to declare an integer array of size 26 because the English language has 26 alphabets a to z. Each index will represent the count of a particular character in the given string.

So we will loop through each character of the given string and will increment their count in the count array at their respective index.

Finally, we will check if the array contains any zero, If yes then it means that the sentence was missing some alphabets and is not a Pangram else if all the values in the array are greater than zero that it is surely a Pangram sentence.

Pangram check using array

So let’s implement the same in Java.

Output

If you have any doubts or suggestion then comment below.

Leave a Reply

Close Menu