Skip to content

Commit d1bb210

Browse files
Added Pangram Checker
1 parent 8faddb8 commit d1bb210

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎src/algo/string/Pangram.java‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class Pangram {
2+
3+
private static boolean isPangram(String str) {
4+
boolean[] pangram = new boolean[26];
5+
6+
for (int i = 0; i < str.length(); i++) {
7+
if (str.charAt(i) >= 'A' && str.charAt(i) <= 'Z')
8+
pangram[str.charAt(i) - 'A'] = true;
9+
else if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z')
10+
pangram[str.charAt(i) - 'a'] = true;
11+
}
12+
13+
for (int i = 0; i < 26; i++)
14+
if (!pangram[i])
15+
return false;
16+
return true;
17+
}
18+
19+
public static void main(String[] args) {
20+
System.out.println(isPangram("The quick brown fox jumps over the lazy dog") ? "The given string is Pangram" : "The given string is not a Pangram");
21+
}
22+
23+
}

0 commit comments

Comments
 (0)