-
Notifications
You must be signed in to change notification settings - Fork 0
/
panagramSentence.java
52 lines (37 loc) · 1.36 KB
/
panagramSentence.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.util.ArrayList;
/**
A pangram is a sentence where every letter of the English alphabet appears at least once.
Given a string sentence containing only lowercase English letters, return true if sentence is a pangram,
or false otherwise.
Example 1:
Input: sentence = "thequickbrownfoxjumpsoverthelazydog"
Output: true
Explanation: sentence contains at least one of every letter of the English alphabet.
Example 2:
Input: sentence = "leetcode"
Output: false
Constraints:
1 <= sentence.length <= 1000
sentence consists of lowercase English letters.
*/
/***********************************************************************
1832. Check if the Sentence Is Pangram
************************************************************************/
public class panagramSentence {
public static void main(String[] args) {
String sentence = "leetcode is life";
int strLength = sentence.length();
ArrayList<Character> checkAlphabet = new ArrayList<>();
for(int i=0; i<strLength; i++) {
checkAlphabet.add(sentence.charAt(i));
}
boolean result = true;
for(int i=97; i<=122; i++) {
if(!checkAlphabet.contains((char) i)) {
result = false;
break;
}
}
System.out.println("result == " + result); // return result;
}
}