Leetcode Problem 1832. Check if the Sentence Is Pangram

1832. Check if the Sentence Is Pangram

Leetcode Solutions

Bit Manipulation Approach

  1. Initialize an integer seen to 0 to act as a bit mask.
  2. Iterate over each character c in the sentence. a. Calculate the index i by subtracting the ASCII value of 'a' from the ASCII value of c. b. Create a bit mask mask by left shifting 1 by i positions. c. Update seen by performing a bitwise OR with mask.
  3. After the loop, check if seen is equal to (1 << 26) - 1, which represents all 26 bits set. If true, return true; otherwise, return false.
UML Thumbnail

Set Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...