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 74326b7 commit 5083579Copy full SHA for 5083579
.plan
@@ -1,3 +1,7 @@
1
+Sep 7, 2024
2
+
3
+* re-solve "1. Two Sum"
4
5
Sep 6, 2024
6
7
* re-solve "49. Group Anagrams"
src/two_sum.py
@@ -1,11 +1,11 @@
class Solution:
def twoSum(self, nums: list[int], target: int) -> list[int]:
- seen: dict[int, int] = {}
+ compliments: dict[int, int] = {}
for i, x in enumerate(nums):
compliment = target - x
- if compliment in seen:
8
- return [seen[compliment], i]
9
- seen[x] = i
+ if compliment in compliments:
+ return [compliments[compliment], i]
+ compliments[x] = i
10
11
- raise ValueError
+ raise ValueError("solution not found")
0 commit comments