Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerRank Pangrams problem solution

YASH PAL, 31 July 202422 January 2026

HackerRank Pangrams problem solution – In this HackerRank Pangrams, problem we have given a sentence determines whether it is a pangram in the English alphabet. Ignore case. Return either pangram or not pangram as appropriate.

A 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

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

Function Description

Complete the function pangrams in the editor. 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.

HackerRank Pangrams problem solution

HackerRank Pangrams problem solution in Python.

s = set(list(input().lower()))
letters = []
for i in range(97, 122):
    letters.append(i)

for i, element in enumerate(s):
    if ord(element) in letters:
        letters.remove(ord(element))

if len(letters) > 0:
    print("not", end=" ")
print("pangram")


Pangrams problem solution in Java.

import java.io.*;
import java.util.*;

public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        try (Scanner sc = new Scanner(System.in)) {
            String line = sc.nextLine();
            String lower = line.toLowerCase();
            lower = lower.replace(" ", "");
            
            Set<Character> chars = new HashSet<Character>();
            for (int i = 0; i < lower.length(); ++i) {
                chars.add(lower.charAt(i));
            }
            if (chars.size() != 26) {
                System.out.print("not ");
            }
            System.out.println("pangram");
        }
    }
}


Problem solution in C++.

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <queue>
#include <string>
#include <fstream>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <ctime>

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define float long double
#define LL long long
#define itn int
#define mp make_pair
#define x first
#define y second

using namespace std;

int main(){

	string s;
	vector<int> a(256, 0);
	getline(cin, s);
	for (int i = 0; i < s.length(); i++){
		a[s[i]]++;
	}
	for (char c = 'a'; c <= 'z'; c++){
		if (a[c] + a[c - 'a' + 'A'] == 0){
			cout << "not pangramn";
			return 0;
		}
	}
	cout << "pangramn";
	
	return 0;
}


Problem solution in C.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char ss[1001];
int mark[26] = {0};

int main(){
	int l, i;
	gets(ss);
	l = strlen(ss);
	for(i=0; i<l; i++){
		if(ss[i]>='a' && ss[i]<='z')mark[ss[i]-'a'] = 1;
		else if(ss[i]>='A' && ss[i]<='Z')mark[tolower(ss[i])-'a'] = 1;

	}


	for(i=0; i<26; i++){
//		printf("%d ", i);
		if(!mark[i])break;
	}
//	printf("n");
	if(i==26)printf("pangramn");
	else printf("not pangramn");
	return 0;
}


Problem solution in JavaScript.

function processData(input) {
    //Enter your code here
    var lowerInput = input.toLowerCase();
    var letterArray = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
    for(var i = 0, l = letterArray.length; i < l; i++) {
        if(lowerInput.toLowerCase().indexOf(letterArray[i]) == -1) {
            console.log('not pangram');
            return false;
        }
    }
    console.log('pangram');
} 

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

Algorithms coding problems solutions AlgorithmsHackerRank

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes