mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 17:56:02 +08:00
Added function in Pangram.java (#3703)
* Added function in Pangram.java Added isPangramIndexOf() function in Pangram.java * Added Tests for new function Added Tests for isPangramIndexOf() function * fixed typo * changed function name * changed function name Co-authored-by: Debasish Biswas <debasishbsws.abc@gmail.com>
This commit is contained in:

committed by
GitHub

parent
b2393d62a0
commit
acf7a86b96
@ -36,4 +36,23 @@ public class Pangram {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a String is Pangram or not by checking if each alhpabet is present or not
|
||||
*
|
||||
* @param s The String to check
|
||||
* @return {@code true} if s is a Pangram, otherwise {@code false}
|
||||
*/
|
||||
public static boolean isPangram2(String s) {
|
||||
if (s.length() < 26) {
|
||||
return false;
|
||||
}
|
||||
s = s.toLowerCase(); // Converting s to Lower-Case
|
||||
for (char i = 'a'; i <= 'z'; i++) {
|
||||
if (s.indexOf(i) == -1) {
|
||||
return false; // if any alphabet is not present, return false
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user