{"id":8370,"date":"2021-04-18T09:35:32","date_gmt":"2021-04-18T16:35:32","guid":{"rendered":"https:\/\/zxi.mytechroad.com\/blog\/?p=8370"},"modified":"2021-04-18T09:36:20","modified_gmt":"2021-04-18T16:36:20","slug":"leetcode-1832-check-if-the-sentence-is-pangram","status":"publish","type":"post","link":"https:\/\/zxi.mytechroad.com\/blog\/hashtable\/leetcode-1832-check-if-the-sentence-is-pangram\/","title":{"rendered":"\u82b1\u82b1\u9171 LeetCode 1832. Check if the Sentence Is Pangram"},"content":{"rendered":"\n<p>A&nbsp;<strong>pangram<\/strong>&nbsp;is a sentence where every letter of the English alphabet appears at least once.<\/p>\n\n\n\n<p>Given a string&nbsp;<code>sentence<\/code>&nbsp;containing only lowercase English letters, return<code>true<\/code><em>&nbsp;if&nbsp;<\/em><code>sentence<\/code><em>&nbsp;is a&nbsp;<strong>pangram<\/strong>, or&nbsp;<\/em><code>false<\/code><em>&nbsp;otherwise.<\/em><\/p>\n\n\n\n<p><strong>Example 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted;crayon:false\"><strong>Input:<\/strong> sentence = \"thequickbrownfoxjumpsoverthelazydog\"\n<strong>Output:<\/strong> true\n<strong>Explanation:<\/strong> sentence contains at least one of every letter of the English alphabet.\n<\/pre>\n\n\n\n<p><strong>Example 2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted;crayon:false\"><strong>Input:<\/strong> sentence = \"leetcode\"\n<strong>Output:<\/strong> false\n<\/pre>\n\n\n\n<p><strong>Constraints:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>1 &lt;= sentence.length &lt;= 1000<\/code><\/li><li><code>sentence<\/code>&nbsp;consists of lowercase English letters.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Solution: Hashset<\/strong><\/h2>\n\n\n\n<p>Time complexity: O(n)<br>Space complexity: O(26)<\/p>\n\n\n\n<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">C++<\/h2>\n<div class=\"tabcontent\">\n\n<pre lang=\"c++\">\nclass Solution {\npublic:\n  bool checkIfPangram(string sentence) {\n    unordered_set<char> s;\n    for (char c : sentence)\n      s.insert(c);\n    return s.size() == 26;\n  }\n};\n<\/pre>\n\n<\/div><h2 class=\"tabtitle\">Python3<\/h2>\n<div class=\"tabcontent\">\n\n<pre lang=\"python\">\nclass Solution:\n  def checkIfPangram(self, sentence: str) -> bool:\n    return len(set(sentence)) == 26\n<\/pre>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>A&nbsp;pangram&nbsp;is a sentence where every letter of the English alphabet appears at least once. Given a string&nbsp;sentence&nbsp;containing only lowercase English letters, returntrue&nbsp;if&nbsp;sentence&nbsp;is a&nbsp;pangram, or&nbsp;false&nbsp;otherwise. Example&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[222,82],"class_list":["post-8370","post","type-post","status-publish","format-standard","hentry","category-hashtable","tag-easy","tag-hashtable","entry","simple"],"_links":{"self":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/8370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/comments?post=8370"}],"version-history":[{"count":2,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/8370\/revisions"}],"predecessor-version":[{"id":8372,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/8370\/revisions\/8372"}],"wp:attachment":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/media?parent=8370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/categories?post=8370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/tags?post=8370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}