Find missing letter of a sentence - Pangram checker

Here I'm going to show simple way to find the missing letter of a sentence using a console application. The sentence "A quick brown fox jumps over the lazy dog" contains every single letter in the alphabet. Such sentences are called pangrams. I am to write a method getMissingLetters, which takes a String, sentence, and returns all the letters it is missing (which prevent it from being a pangram).this is the interface of the application:


This class is responsible for logic:



That is all
Enjoy..!!

5 comments:

  1. Good. Better to rename the title as pangram checker

    ReplyDelete
  2. Right now, you are iterating the loop for the entire length of the sentence. That will cost you more time if a sentence is a long one, like a paragraph.
    One other way to achieve the same is, if you run the loop on array of 26 alphabets, for eg. arr[26]. Run the loop on array and search the sentence to see if that alphabet is missing in the sentence. Reiterate 26 times and whenever you find such an alphabet, record that. In the end print the recorded alphabets.
    By doing this, you run the loop for only 26 times, no matter how long the sentence.
    I have a code that I can share, if you want.

    ReplyDelete
    Replies
    1. Agree!
      Please share your code here if you like :)

      Delete