# HackerRank Pangrams Solution

Hello Programmers, In this post, you will learn how to solve HackerRank Pangrams Solution. This problem is a part of the HackerRank Algorithms Series.

One more thing to add, don’t straight away look for the solutions, first try to solve the problems by yourself. If you find any difficulty after trying several times, then look for the solutions. We are going to solve the HackerRank Algorithms problems using C, CPP, JAVA, PYTHON, JavaScript & SCALA Programming Languages.

## HackerRank Pangrams Solution

pangram is a string that contains every letter of the alphabet. Given a sentence determine whether it is a pangram in the English alphabet. Ignore case. Return either `pangram` or `not pangram` as appropriate.

Example

s = ”The quick brown fox jumps over the lazy dog”

The string contains all letters in the English alphabet, so return `pangram`.

Function Description

Complete the function pangrams in the editor below. It should return the string `pangram` if the input string is a pangram. Otherwise, it should return `not pangram`.

pangrams has the following parameter(s):

• string s: a string to test

Returns

• string: either `pangram` or `not pangram`

## Input Format

A single line with string s.

## Constraints

• 0 < length of s <= 103
• Each character of ss[i] ∈ {a – z, A – Z, space}

Sample Input 0

We promptly judged antique ivory buckles for the next prize

Sample Output 0

pangram

Explanation 0

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

Sample Input 1

We promptly judged antique ivory buckles for the prize

Sample Output 1

not pangram

Explanation 1

The string lacks an `x`

## HackerRank Pangrams Solution

### HackerRank Pangrams Solution in C

```#include<stdio.h>
char st[100000];
int i,ind[1000];
int main()
{
while(gets(st))
{
for(i='A';i<='Z';i++)
ind[i]=0;

for(i=0;st[i];i++)
{
if(st[i]>='a' && st[i]<='z')
st[i]-=32;

ind[st[i]]++;
}
for(i='A';i<='Z';i++)
if(ind[i]==0)
break;

if(i=='Z'+1)
printf("pangram\n");
else
printf("not pangram\n");
}
return 0;
}```

### HackerRank Pangrams Solution in Cpp

```#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(){
string s;
getline(cin, s);
int cnt[26];
for(int i =0; i < 26; ++i)
cnt[i] = 0;
for(int i = 0; i < s.length(); ++i){
if(s[i] >= 'a' && s[i] <= 'z'){
cnt[s[i] - 'a']++;
}
if(s[i] >= 'A' && s[i] <= 'Z'){
cnt[s[i] - 'A']++;
}
}
bool f = true;
for(int i = 0; i < 26; ++i){
if(cnt[i] == 0){
f = false;
break;
}
}
if(f){
cout<<"pangram";
}
else{
cout<<"not pangram";
}
return 0;
}```

### HackerRank Pangrams Solution in Java

```import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Solution {

void solve() throws IOException {
boolean[] a=new boolean[26];
s=s.toLowerCase();
for(int i=0;i<s.length();i++)
if(s.charAt(i)>='a'&&s.charAt(i)<='z')a[s.charAt(i)-'a']=true;
boolean good=true;
for(int i=0;i<26;i++)
if(!a[i]){
good=false;
break;
}
if(good)
out.println("pangram");
else
out.println("not pangram");
}

public static void main(String[] args) throws IOException {
new Solution().run();
}

void run() throws IOException {
tokenizer = null;
out = new PrintWriter(new OutputStreamWriter(System.out));
//		out = new PrintWriter(new FileWriter("output.txt"));
solve();
out.flush();

}

StringTokenizer tokenizer;
PrintWriter out;

int nextInt() throws IOException {
return Integer.parseInt(nextToken());
}

long nextLong() throws IOException {
return Long.parseLong(nextToken());
}

double nextDouble() throws IOException {
return Double.parseDouble(nextToken());
}

String nextToken() throws IOException {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
}
}
}```

### HackerRank Pangrams Solution in Python

```from string import ascii_lowercase
x = list(ascii_lowercase)
for y in raw_input():
y = y.lower()
if y in x:
x.pop(x.index(y))
if len(x) == 0:
print "pangram"
else:
print "not pangram"```

### HackerRank Pangrams Solution using JavaScript

```process.stdin.resume();
var _input = '';
process.stdin.on('data', function (data) {
_input += data;
});
process.stdin.on('end', function () {
solve(_input);
});

function solve(input) {
var letters = {};
for (var i = 0; i < input.length; ++i) {
letters[input.charAt(i).toLowerCase()] = true;
}
var isPangram = true;
var alphabet = 'abcdefghijklmnopqrstuvwxyz';
for (i = 0; i < alphabet.length; ++i) {
isPangram = isPangram && letters[alphabet.charAt(i)];
}
console.log((isPangram ? '' : 'not ') + 'pangram');```

### HackerRank Pangrams Solution in Scala

```import scala.collection._

object Solution {

def isPanagram(s: String): Boolean = {
val alphabet = mutable.HashSet[Char]()
for (c <- s if c.isLetter) alphabet.add(c.toLower)
return alphabet.size == 26
}

def main(args: Array[String]) {
val s = io.Source.stdin.getLines().take(1).next
if (isPanagram(s)) println("pangram")
else println("not pangram")
}
}```

### HackerRank Pangrams Solution in Pascal

```{\$r-,s-,q-,i-,o+}
var
s:ansistring;c:char;i:longint;
f:array['a'..'z']of boolean;
begin