CREATE OWN LIBRARY


Description

A sentence is known as a pangram because it contains every letter of the alphabet.

Eg: “The quick brown fox jumps over the lazy dog”

Given a sentence, determine whether it is a Pangram.

Ignore Case.

Example 1: We promptly judged antique ivory buckles for the next prize.

O/P: Pangram

Explanation: All of the letters of the alphabet are present in the string.

Example 2: We promptly judged antique ivory buckles for the prize.

O/P: not Pangram

Explanation: The string lacks an X

Algorithm

We have to find whether each letter in English alphabet is present in the string.

 

Algorithm

Step 1: Store all the English letter’s in a variable ‘ch’

Step 2: Strip of all spaces in the string to move it consecutive letters of single string

            and store it in variable ‘k’

Step 3: Convert k to lowercase

Step 4: Remove the duplicate elements in k.

Step 5: for each letter in ch

                    if letter not present in k

                               return not Pangram and break from the loop

                    else

                              initialize available j with 0

Step 6: Repeat Step 5 until reach end of ch

Step 7: if the value of j == 0 then return “Pangram”

Code

Time Complexity:

Strip( ):                              O(n)                 /to strip spaces

lower case( ):                    O(n)                    /to lowercase whole array

set( ):                                 O(n)                     /worst case

                                          O(1)                    /Average case

Checking if i in ‘k’     / O(1) // Hashing O(1)

                         Total : O(n)

Space Complexity: O(n)  // Creating new array