Facile 0 résolus 0 % de réussite

Pangram Check

A pangram contains every English letter at least once.

Ce que vous allez apprendre

  • Collect the distinct letters of a text
  • Ignore case and non-letters
  • Compare against the 26-letter alphabet

Problème

Afficher la traduction

A pangram contains every English letter at least once. Determine whether the text is a pangram. Ignore case, spaces, digits, and punctuation.

Implement pangram_check(text).

Input

text: The text to inspect.

Output

Return true if all 26 letters appear, otherwise false.

Contraintes

0 ≤ text length ≤ 100,000. Input contains printable ASCII characters. Only letters A–Z and a–z count.

Exemples

Exemple 1
Entrée :
text = "The quick brown fox jumps over the lazy dog."

Sortie attendue :
expected = True
Entrée :
std::string text = "The quick brown fox jumps over the lazy dog.";

Sortie attendue :
bool expected = true;
Entrée :
string text = "The quick brown fox jumps over the lazy dog.";

Sortie attendue :
bool expected = true;

Explication

Every letter from a through z appears at least once. Capital T counts as t.

Exemple 2
Entrée :
text = "abcdefghijklmnopqrstuvwxy"

Sortie attendue :
expected = False
Entrée :
std::string text = "abcdefghijklmnopqrstuvwxy";

Sortie attendue :
bool expected = false;
Entrée :
string text = "abcdefghijklmnopqrstuvwxy";

Sortie attendue :
bool expected = false;

Explication

This text contains a through y, but it has no z. One missing letter makes it false.

Comment l'aborder

Essayez d'abord seul, puis ouvrez les indices un par un.

Indice 1

Normalize the text so letter case does not matter.

Indice 2

Track which of the 26 letters have appeared at least once.

Indice 3

Ignore every non-letter character completely, including spaces and punctuation.

Complexité attendue

O(n) time, O(1) extra space

Références

Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.

Apprenez des autres

Solutions de la communauté

Aucune solution publiée pour l'instant. Résolvez ce défi pour partager la première.