Skip to content

Commit

Permalink
New Problem Solution - "1832. Check if the Sentence Is Pangram"
Browse files Browse the repository at this point in the history
  • Loading branch information
haoel committed Apr 20, 2021
1 parent 2e55b86 commit 0be935a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
};

0 comments on commit 0be935a

Please sign in to comment.