We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7db46d5 commit 9028c5cCopy full SHA for 9028c5c
two-sum/Bumsu-Yi.py
@@ -1,5 +1,15 @@
1
"""
2
https://leetcode.com/problems/two-sum/
3
4
-#
5
+
6
+class Solution:
7
+ def twoSum(self, nums: List[int], target: int) -> List[int]:
8
+ numMap = {}
9
10
+ for i in range(len(nums)):
11
+ complement = target - nums[i]
12
+ if complement in numMap:
13
+ return [numMap[complement], i]
14
15
+ numMap[nums[i]] = i
valid-anagram/Bumsu-Yi.py
@@ -1,3 +1,17 @@
https://leetcode.com/problems/valid-anagram/
+ def isAnagram(self, s: str, t: str) -> bool:
+ my_dict1 = {}
+ my_dict2 = {}
+ for char in s:
+ my_dict1[char] = my_dict1.get(char, 0) + 1
+ for char in t:
+ my_dict2[char] = my_dict2.get(char, 0) + 1
16
17
+ return my_dict1 == my_dict2
0 commit comments