forked from doocs/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add leetcode solutions: No.1832. Check if the Sentence is Pangram
- Loading branch information
Showing
4 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
solution/1800-1899/1832.Check if the Sentence Is Pangram/Solution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Solution { | ||
public boolean checkIfPangram(String sentence) { | ||
int res = 0; | ||
for (int i = 0; i < sentence.length(); ++i) { | ||
int diff = sentence.charAt(i) - 'a'; | ||
res |= (1 << diff); | ||
if (res == 0x3ffffff) return true; | ||
} | ||
return false; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
solution/1800-1899/1832.Check if the Sentence Is Pangram/Solution.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Solution: | ||
def checkIfPangram(self, sentence: str) -> bool: | ||
return len(set(sentence)) == 26 |