Re: [LeetCode] 刷到面試 Grind169 C++

看板Marginalman作者 (彗星雷達)時間2年前 (2023/03/15 17:00), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串7/14 (看更多)
242. Valid Anagram easy題 哈希表 第一次遇到這個 但還滿好懂得 class Solution { public: bool isAnagram(string s, string t) { int hash[26] = {0}; if(s.length()!=t.length()) return false; for(int i=0;i<s.length();i++){ hash[s[i]-'a']++; hash[t[i]-'a']--; } for(int j=0;j<26;j++){ if(hash[j]!=0) return false; } return true; } }; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.136.220 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1678870847.A.2E6.html
文章代碼(AID): #1a4Oa_Bc (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1a4Oa_Bc (Marginalman)