• + 0 comments

    Here is a TypeScrip solution with O(n) time and O(1) space.

    I know the apace can also be consider O(n) because it grows; however, it will never be bigger then 26 (size of alphabet) so it can be consider constant space.

    function pangrams(s: string): string {
        const alpha: string = "abcdefghigklmnopqrstuvwxyz"
        let content = new Set()
        for (let ch of s.toLocaleLowerCase()) {
            if (alpha.includes(ch)) {
                content.add(ch)
            }
        }
        
        if (content.size === 25) 
            return "pangram ";
        else
            return "not pangram ";
    }