8000 New Problem Solution - "1832. Check if the Sentence Is Pangram" · royeLin/leetcode_cpp@0be935a · GitHub
[go: up one dir, main page]

Skip to content

Commit 0be935a

Browse files
committed
New Problem Solution - "1832. Check if the Sentence Is Pangram"
1 parent 2e55b86 commit 0be935a

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

README.md

Copy file name to clipboard
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LeetCode
99

1010
| # | Title | Solution | Difficulty |
1111
|---| ----- | -------- | ---------- |
12+
|1832|[Check if the Sentence Is Pangram](https://leetcode.com/problems/check-if-the-sentence-is-pangram/) | [C++](./algorithms/cpp/checkIfTheSentenceIsPangram/CheckIfTheSentenceIsPangram.cpp)|Easy|
1213
|1829|[Maximum XOR for Each Query](https://leetcode.com/problems/maximum-xor-for-each-query/) | [C++](./algorithms/cpp/maximumXorForEachQuery/MaximumXorForEachQuery.cpp)|Medium|
1314
|1828|[Queries on Number of Points Inside a Circle](https://leetcode.com/problems/queries-on-number-of-points-inside-a-circle/) | [C++](./algorithms/cpp/queriesOnNumberOfPointsInsideACircle/QueriesOnNumberOfPointsInsideACircle.cpp)|Medium|
1415
|1827|[Minimum Operations to Make the Array Increasing](https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing/) | [C++](./algorithms/cpp/minimumOperationsToMakeTheArrayIncreasing/MinimumOperationsToMakeTheArrayIncreasing.cpp)|Easy|
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Source : https://leetcode.com/problems/check-if-the-sentence-is-pangram/
2+
// Author : Hao Chen
3+
// Date : 2021-04-20
4+
5+
/*****************************************************************************************************
6+
*
7+
* A pangram is a sentence where every letter of the English alphabet appears at least once.
8+
*
9+
* Given a string sentence containing only lowercase English letters, return true if sentence is a
10+
* pangram, or false otherwise.
11+
*
12+
* Example 1:
13+
*
14+
* Input: sentence = "thequickbrownfoxjumpsoverthelazydog"
15+
* Output: true
16+
* Explanation: sentence contains at least one of every letter of the English alphabet.
17+
*
18+
* Example 2:
19+
*
20+
* Input: sentence = "leetcode"
21+
* Output: false
22+
*
23+
* Constraints:
24+
*
25+
* 1 <= sentence.length <= 1000
26+
* sentence consists of lowercase English letters.
27+
******************************************************************************************************/
28+
29+
class Solution {
30+
public:
31+
bool checkIfPangram(string sentence) {
32+
bool stat[26] = {false};
33+
for(auto& c: sentence) {
34+
stat[c - 'a'] = true;
35+
}
36+
for(auto& s : stat) {
37+
if (!s) return false;
38+
}
39+
return true;
40+
}
41+
};

0 commit comments

Comments
 (0)
0