New Problem Solution - "1832. Check if the Sentence Is Pangram"
This commit is contained in:
parent
2e55b8691e
commit
0be935a8aa
@ -9,6 +9,7 @@ LeetCode
|
||||
|
||||
| # | Title | Solution | Difficulty |
|
||||
|---| ----- | -------- | ---------- |
|
||||
|1832|[Check if the Sentence Is Pangram](https://leetcode.com/problems/check-if-the-sentence-is-pangram/) | [C++](./algorithms/cpp/checkIfTheSentenceIsPangram/CheckIfTheSentenceIsPangram.cpp)|Easy|
|
||||
|1829|[Maximum XOR for Each Query](https://leetcode.com/problems/maximum-xor-for-each-query/) | [C++](./algorithms/cpp/maximumXorForEachQuery/MaximumXorForEachQuery.cpp)|Medium|
|
||||
|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|
|
||||
|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|
|
||||
|
@ -0,0 +1,41 @@
|
||||
// Source : https://leetcode.com/problems/check-if-the-sentence-is-pangram/
|
||||
// Author : Hao Chen
|
||||
// Date : 2021-04-20
|
||||
|
||||
/*****************************************************************************************************
|
||||
*
|
||||
* 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.
|
||||
******************************************************************************************************/
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
bool checkIfPangram(string sentence) {
|
||||
bool stat[26] = {false};
|
||||
for(auto& c: sentence) {
|
||||
stat[c - 'a'] = true;
|
||||
}
|
||||
for(auto& s : stat) {
|
||||
if (!s) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user