MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / isPangram2

Method isPangram2

src/main/java/com/thealgorithms/strings/Pangram.java:68–79  ·  view source on GitHub ↗

Checks if a String is Pangram or not by checking if each alphabet is present or not @param s The String to check @return true if s is a Pangram, otherwise false

(String s)

Source from the content-addressed store, hash-verified

66 * @return {@code true} if s is a Pangram, otherwise {@code false}
67 */
68 public static boolean isPangram2(String s) {
69 if (s.length() < 26) {
70 return false;
71 }
72 s = s.toLowerCase(); // Converting s to Lower-Case
73 for (char i = 'a'; i <= 'z'; i++) {
74 if (s.indexOf(i) == -1) {
75 return false; // if any alphabet is not present, return false
76 }
77 }
78 return true;
79 }
80}

Callers 1

testPangramMethod · 0.95

Calls 3

lengthMethod · 0.80
indexOfMethod · 0.80
toLowerCaseMethod · 0.45

Tested by 1

testPangramMethod · 0.76