nathanwailes

LeetCode 242 - Valid Anagram - 2022.12.30 solution

Dec 30th, 2022
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. class Solution:
  2.     def isAnagram(self, s: str, t: str) -> bool:
  3.         s_dict = defaultdict(int)
  4.         for c in s:
  5.             s_dict[c] += 1
  6.  
  7.         t_dict = defaultdict(int)
  8.         for c in t:
  9.             t_dict[c] += 1
  10.        
  11.         return s_dict == t_dict
Advertisement
Add Comment
Please, Sign In to add comment