Skip to content

Commit d5bd7a1

Browse files
committed
1832. 判断句子是否为全字母句
1 parent 22e9014 commit d5bd7a1

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
|1038|[从二叉搜索树到更大和树](https://leetcode.cn/problems/binary-search-tree-to-greater-sum-tree/)|[JavaScript](./algorithms/binary-search-tree-to-greater-sum-tree.js)|Medium|
174174
|1047|[删除字符串中的所有相邻重复项](https://leetcode.cn/problems/remove-all-adjacent-duplicates-in-string/)|[JavaScript](./algorithms/remove-all-adjacent-duplicates-in-string.js)|Easy|
175175
|1780|[判断一个数字是否可以表示成三的幂的和](https://leetcode.cn/problems/check-if-number-is-a-sum-of-powers-of-three/)|[JavaScript](./algorithms/check-if-number-is-a-sum-of-powers-of-three.js)|Medium|
176+
|1832|[判断句子是否为全字母句](https://leetcode.cn/problems/check-if-the-sentence-is-pangram/)|[JavaScript](./algorithms/check-if-the-sentence-is-pangram.js)|Easy|
176177
|面试题 04.12|[面试题 04.12. 求和路径](https://leetcode.cn/problems/paths-with-sum-lcci/)|[JavaScript](./algorithms/paths-with-sum-lcci.js)|Medium|
177178
|面试题 02.07|[面试题 02.07. 链表相交](https://leetcode.cn/problems/intersection-of-two-linked-lists-lcci/)|[JavaScript](./algorithms/intersection-of-two-linked-lists-lcci.js)|Easy|
178179
|剑指 Offer 05. 替换空格|[剑指 Offer 05. 替换空格](https://leetcode.cn/problems/ti-huan-kong-ge-lcof/)|[JavaScript](./algorithms/ti-huan-kong-ge-lcof.js)|Easy|

Diff for: algorithms/check-if-the-sentence-is-pangram.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param {string} sentence
3+
* @return {boolean}
4+
*/
5+
var checkIfPangram = function (sentence) {
6+
const map = Array(26).fill(0);
7+
8+
for (let i = 0; i < sentence.length; i++) {
9+
const index = sentence[i].charCodeAt() - 97;
10+
map[index]++;
11+
}
12+
for (let i = 0; i < map.length; i++) {
13+
if (map[i] === 0) {
14+
return false;
15+
}
16+
}
17+
18+
return true;
19+
};

0 commit comments

Comments
 (0)