00:00

Problem Statement

Input/Output Examples

Visual Explanation

A letter that has already been seen does not change anything, so the distinct counter grows only when a new letter appears. That counter is what allows an early exit without checking the whole array.

Approaches

Both approaches lowercase each character and consider only a to z. The first can stop early.

Java Solutions

Each tab is a complete program that runs on Java 17 or later. Both programs print the same output for the same inputs.

Complexity Analysis

Here n is the length of the string. Both approaches read each character at most once and remember at most 26 letters.

Interview Tips and Recommended Approach

  • Ignore non-letters explicitly. Counting distinct characters without a filter would let spaces and digits fill the 26 slots.
  • Mention the bitmask variant. An int with 26 bits can replace the array: the string is a pangram when the mask equals (1 << 26) - 1.
  • Add a quick length check. A string shorter than 26 characters cannot be a pangram.
  • Ask about other alphabets. Accented or non-English letters need a different definition of "every letter".

Recommended Approach: boolean[26] With Early Exit

Why: it uses a fixed 26-slot array and stops as soon as the answer is known, which makes it both memory-light and fast on real text.