-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path242.py
More file actions
40 lines (26 loc) · 676 Bytes
/
Copy path242.py
File metadata and controls
40 lines (26 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'''242. Valid Anagram
Created on 2024-12-18 14:38:39
2024-12-18 14:52:20
@author: MilkTea_shih
'''
#%% Packages
#%% Variable
#%% Functions
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
if len(s) != len(t):
return False
seen_table: dict[str, int] = {} #letter: count
for letter in s:
seen_table[letter] = seen_table.get(letter, 0) + 1
for letter in t:
if seen_table.get(letter, 0) > 0:
seen_table[letter] -= 1
else:
return False
return True
#%% Main Function
#%% Main
if __name__ == '__main__':
pass
#%%