init: hot100 algo project with .gitignore

This commit is contained in:
2026-04-29 11:36:37 +08:00
commit c39ae0d3e1
2 changed files with 48 additions and 0 deletions

15
01-two-sum/solution.py Normal file
View File

@@ -0,0 +1,15 @@
from typing import List
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
hash = {}
for i, num in enumerate(nums):
another = target - num
if another in hash:
return [hash[another], i]
hash[num] = i
if __name__ == "__main__":
res = Solution().twoSum([2,7,11,15], 9)
print(res)