diff --git a/383-240524-pass/main.py b/383-240524-pass/main.py new file mode 100644 index 0000000..00a7fca --- /dev/null +++ b/383-240524-pass/main.py @@ -0,0 +1,27 @@ +class Solution: + def canConstruct(self, ransomNote: str, magazine: str) -> bool: + ran_dic = {} + mag_dic = {} + for l in ransomNote: + if l not in ran_dic: + ran_dic[l] = 1 + else: + ran_dic[l] += 1 + for l in magazine: + if l not in mag_dic: + mag_dic[l] = 1 + else: + mag_dic[l] += 1 + print(ran_dic) + print(mag_dic) + for key in ran_dic: + if key not in mag_dic: + return False + if ran_dic[key] > mag_dic[key]: + return False + return True + +sol = Solution() +print(sol.canConstruct("a", "b")) +print(sol.canConstruct("aa", "ab")) +print(sol.canConstruct("aa", "aab")) \ No newline at end of file