Skip to content

Commit 7a8b827

Browse files
committed
Add two sum
1 parent 5793c3d commit 7a8b827

File tree

8 files changed

+210
-4
lines changed

8 files changed

+210
-4
lines changed

Diff for: .gitignore

+188-3
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,123 @@
1+
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
2+
3+
# Created by https://www.gitignore.io/api/windows,visualstudiocode,jetbrains+all,python
4+
# Edit at https://www.gitignore.io/?templates=windows,visualstudiocode,jetbrains+all,python
5+
6+
### JetBrains+all ###
7+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
8+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
9+
10+
# User-specific stuff
11+
.idea/**/workspace.xml
12+
.idea/**/tasks.xml
13+
.idea/**/usage.statistics.xml
14+
.idea/**/dictionaries
15+
.idea/**/shelf
16+
17+
# Generated files
18+
.idea/**/contentModel.xml
19+
20+
# Sensitive or high-churn files
21+
.idea/**/dataSources/
22+
.idea/**/dataSources.ids
23+
.idea/**/dataSources.local.xml
24+
.idea/**/sqlDataSources.xml
25+
.idea/**/dynamic.xml
26+
.idea/**/uiDesigner.xml
27+
.idea/**/dbnavigator.xml
28+
29+
# Gradle
30+
.idea/**/gradle.xml
31+
.idea/**/libraries
32+
33+
# Gradle and Maven with auto-import
34+
# When using Gradle or Maven with auto-import, you should exclude module files,
35+
# since they will be recreated, and may cause churn. Uncomment if using
36+
# auto-import.
37+
# .idea/modules.xml
38+
# .idea/*.iml
39+
# .idea/modules
40+
# *.iml
41+
# *.ipr
42+
43+
# CMake
44+
cmake-build-*/
45+
46+
# Mongo Explorer plugin
47+
.idea/**/mongoSettings.xml
48+
49+
# File-based project format
50+
*.iws
51+
52+
# IntelliJ
53+
out/
54+
55+
# mpeltonen/sbt-idea plugin
56+
.idea_modules/
57+
58+
# JIRA plugin
59+
atlassian-ide-plugin.xml
60+
61+
# Cursive Clojure plugin
62+
.idea/replstate.xml
63+
64+
# Crashlytics plugin (for Android Studio and IntelliJ)
65+
com_crashlytics_export_strings.xml
66+
crashlytics.properties
67+
crashlytics-build.properties
68+
fabric.properties
69+
70+
# Editor-based Rest Client
71+
.idea/httpRequests
72+
73+
# Android studio 3.1+ serialized cache file
74+
.idea/caches/build_file_checksums.ser
75+
76+
### JetBrains+all Patch ###
77+
# Ignores the whole .idea folder and all .iml files
78+
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
79+
80+
.idea/
81+
82+
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
83+
84+
*.iml
85+
modules.xml
86+
.idea/misc.xml
87+
*.ipr
88+
89+
# Sonarlint plugin
90+
.idea/sonarlint
91+
92+
### Python ###
193
# Byte-compiled / optimized / DLL files
294
__pycache__/
395
*.py[cod]
96+
*$py.class
497

598
# C extensions
699
*.so
7100

8101
# Distribution / packaging
9102
.Python
10-
env/
11103
build/
12104
develop-eggs/
13105
dist/
14106
downloads/
15107
eggs/
108+
.eggs/
16109
lib/
17110
lib64/
18111
parts/
19112
sdist/
20113
var/
114+
wheels/
115+
pip-wheel-metadata/
116+
share/python-wheels/
21117
*.egg-info/
22118
.installed.cfg
23119
*.egg
120+
MANIFEST
24121

25122
# PyInstaller
26123
# Usually these files are written by a python script from a template
@@ -35,20 +132,108 @@ pip-delete-this-directory.txt
35132
# Unit test / coverage reports
36133
htmlcov/
37134
.tox/
135+
.nox/
38136
.coverage
137+
.coverage.*
39138
.cache
40139
nosetests.xml
41140
coverage.xml
141+
*.cover
142+
.hypothesis/
143+
.pytest_cache/
42144

43145
# Translations
44146
*.mo
45147
*.pot
46148

47-
# Django stuff:
48-
*.log
149+
# Scrapy stuff:
150+
.scrapy
49151

50152
# Sphinx documentation
51153
docs/_build/
52154

53155
# PyBuilder
54156
target/
157+
158+
# pyenv
159+
.python-version
160+
161+
# pipenv
162+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
163+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
164+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
165+
# install all needed dependencies.
166+
#Pipfile.lock
167+
168+
# celery beat schedule file
169+
celerybeat-schedule
170+
171+
# SageMath parsed files
172+
*.sage.py
173+
174+
# Spyder project settings
175+
.spyderproject
176+
.spyproject
177+
178+
# Rope project settings
179+
.ropeproject
180+
181+
# Mr Developer
182+
.mr.developer.cfg
183+
.project
184+
.pydevproject
185+
186+
# mkdocs documentation
187+
/site
188+
189+
# mypy
190+
.mypy_cache/
191+
.dmypy.json
192+
dmypy.json
193+
194+
# Pyre type checker
195+
.pyre/
196+
197+
### VisualStudioCode ###
198+
.vscode/*
199+
!.vscode/settings.json
200+
!.vscode/tasks.json
201+
!.vscode/launch.json
202+
!.vscode/extensions.json
203+
204+
### VisualStudioCode Patch ###
205+
# Ignore all local history of files
206+
.history
207+
208+
### Windows ###
209+
# Windows thumbnail cache files
210+
Thumbs.db
211+
Thumbs.db:encryptable
212+
ehthumbs.db
213+
ehthumbs_vista.db
214+
215+
# Dump file
216+
*.stackdump
217+
218+
# Folder config file
219+
[Dd]esktop.ini
220+
221+
# Recycle Bin used on file shares
222+
$RECYCLE.BIN/
223+
224+
# Windows Installer files
225+
*.cab
226+
*.msi
227+
*.msix
228+
*.msm
229+
*.msp
230+
231+
# Windows shortcuts
232+
*.lnk
233+
234+
# End of https://www.gitignore.io/api/windows,visualstudiocode,jetbrains+all,python
235+
236+
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
237+
238+
venv
239+
.vscode

Diff for: leetcode/__init__.py

Whitespace-only changes.

Diff for: leetcode/algorithms/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from typing import List
2+
3+
14
class Solution:
25
def twoSum(self, nums: List[int], target: int) -> List[int]:
36
mapping = {}
47

58
for index, value in enumerate(nums):
69
if target - value in mapping:
7-
return (mapping[target - value], index)
10+
return [mapping[target - value], index]
811
else:
912
mapping[value] = index

Diff for: setup.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from setuptools import setup
2+
3+
setup(
4+
name='LeetCode',
5+
version='0.0.1',
6+
description='Solutions to LeetCode',
7+
test_suite='tests'
8+
)

Diff for: tests/__init__.py

Whitespace-only changes.

Diff for: tests/algorithms/0001_two_sum_test.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import unittest
2+
from leetcode.algorithms.l0001_two_sum import Solution
3+
4+
5+
class TestTwoSum(unittest.TestCase):
6+
def test_two_sum(self):
7+
nums = [2, 7, 11, 15]
8+
target = 9
9+
10+
self.assertListEqual([0, 1], Solution().twoSum(nums, target))

Diff for: tests/algorithms/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)