1832. Check if the Sentence Is Pangram LeetCode Solution

In this guide, you will get 1832. Check if the Sentence Is Pangram LeetCode Solution with the best time and space complexity. The solution to Check if the Sentence Is Pangram problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.

Table of Contents

  1. Problem Statement
  2. Complexity Analysis
  3. Check if the Sentence Is Pangram solution in C++
  4. Check if the Sentence Is Pangram solution in Java
  5. Check if the Sentence Is Pangram solution in Python
  6. Additional Resources
1832. Check if the Sentence Is Pangram LeetCode Solution image

Problem Statement of Check if the Sentence Is Pangram

A pangram is a sentence where every letter of the English alphabet appears at least once.
Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.

Example 1:

Input: sentence = “thequickbrownfoxjumpsoverthelazydog”
Output: true
Explanation: sentence contains at least one of every letter of the English alphabet.

Example 2:

Input: sentence = “leetcode”
Output: false

Constraints:

1 <= sentence.length <= 1000
sentence consists of lowercase English letters.

Complexity Analysis

  • Time Complexity: O(n)
  • Space Complexity: O(26) = O(1)

1832. Check if the Sentence Is Pangram LeetCode Solution in C++

class Solution {
 public:
  bool checkIfPangram(string sentence) {
    return unordered_set(sentence.begin(), sentence.end()).size() == 26;
  }
};
/* code provided by PROGIEZ */

1832. Check if the Sentence Is Pangram LeetCode Solution in Java

class Solution {
  public boolean checkIfPangram(String sentence) {
    Set<Character> seen = new HashSet<>();

    for (final char c : sentence.toCharArray())
      seen.add(c);

    return seen.size() == 26;
  }
}
// code provided by PROGIEZ

1832. Check if the Sentence Is Pangram LeetCode Solution in Python

class Solution:
  def checkIfPangram(self, sentence: str) -> bool:
    return len(set(sentence)) == 26
# code by PROGIEZ

Additional Resources

See also  910. Smallest Range II LeetCode Solution

Happy Coding! Keep following PROGIEZ for more updates and solutions.