Pangram

package com.thealgorithms.strings;

/**
 * Wikipedia: https://en.wikipedia.org/wiki/Pangram
 */
public class Pangram {

    /**
     * Driver Code
     */
    public static void main(String[] args) {
        assert isPangram("The quick brown fox jumps over the lazy dog");
        assert !isPangram("The quick brown fox jumps over the azy dog");
        /* not exists l character */
    }

    /**
     * Check if a string is a pangram string or not
     *
     * @param s string to check
     * @return {@code true} if given string is pangram, otherwise {@code false}
     */
    public static boolean isPangram(String s) {
        boolean[] marked = new boolean[26];
        /* by default all letters don't exists */
        char[] values = s.toCharArray();
        for (char value : values) {
            if (Character.isLetter(value)) {
                int index = Character.isUpperCase(value) ? value - 'A' : value - 'a';
                marked[index] = true;
                /* mark current character exists */
            }
        }

        for (boolean b : marked) {
            if (!b) {
                return false;
            }
        }
        return true;
    }
}
Algerlogo

Β© Alger 2022

About us

We are a group of programmers helping each other build new things, whether it be writing complex encryption programs, or simple ciphers. Our goal is to work together to document and model beautiful, helpful and interesting algorithms using code. We are an open-source community - anyone can contribute. We check each other's work, communicate and collaborate to solve problems. We strive to be welcoming, respectful, yet make sure that our code follows the latest programming guidelines.