Re: [閒聊] 每日LeetCode已回收

看板Marginalman作者 (みけねこ的鼻屎)時間3年前 (2022/10/17 09:42), 編輯推噓2(200)
留言2則, 2人參與, 3年前最新討論串49/719 (看更多)
1832. Check if the Sentence Is Pangram 給予一個字串如果該字串包含所有26個字母返回true,否則false。 Example 1: Input: sentence = "thequickbrownfoxjumpsoverthelazydog" Output: true Explanation: sentence contains at least one of every letter of the English alphabet. 思路: 1.把所有字元加入Set 2.每次加入完先檢查Set的大小是否是26是的話直接返回。 Java Code: class Solution { public boolean checkIfPangram(String sentence) { Set<Character> set = new HashSet<>(); for(char c : sentence.toCharArray()) { set.add(c); if(set.size() == 26) return true; } return false; } } https://i.imgur.com/Mi7Z2s9.png
我這輩子只解的出Eazy了 -- https://i.imgur.com/bFRiqA3.jpg
-- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.159.111.108 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1665970972.A.AF5.html

10/17 12:08, 3年前 , 1F
大師
10/17 12:08, 1F

10/17 18:39, 3年前 , 2F
終於有簡單的 不然前兩天的都要吐了==
10/17 18:39, 2F
文章代碼(AID): #1ZJBCShr (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1ZJBCShr (Marginalman)