From c39ae0d3e1547b0fe3a4c98d332510b90b5c9229 Mon Sep 17 00:00:00 2001 From: rain-bus Date: Wed, 29 Apr 2026 11:36:37 +0800 Subject: [PATCH] init: hot100 algo project with .gitignore --- .gitignore | 33 +++++++++++++++++++++++++++++++++ 01-two-sum/solution.py | 15 +++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .gitignore create mode 100644 01-two-sum/solution.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8480e8a --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +__pycache__/ +*.pyc +*.pyo +*.pyd +.Python +*.so +*.egg +*.egg-info/ +dist/ +build/ +.eggs/ +*.whl + +.env +.venv +env/ +venv/ +ENV/ + +.idea/ +.vscode/ +*.swp +*.swo +*~ + +.DS_Store +Thumbs.db + +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ +htmlcov/ +.coverage diff --git a/01-two-sum/solution.py b/01-two-sum/solution.py new file mode 100644 index 0000000..2c4e4e6 --- /dev/null +++ b/01-two-sum/solution.py @@ -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)