Skip to content

Commit b7ca5ce

Browse files
committed
2 sum
1 parent 6dbbd10 commit b7ca5ce

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@
4040

4141

4242

43-
44-
45-
43+
## Array Easy
44+
| # | Title | Solution | Time | Space | Video|
45+
| --- | ----- | -------- | ---- | ----- | ---- |
46+
|1| [Two Sum](https://leetcode.com/problems/two-sum/) | [Python](./array/1.py) | _O(n)_| _O(n)_ |https://www.youtube.com/watch?v=uajne4jeGaA|
4647

4748

4849

array/1.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution(object):
2+
def twoSum(self, nums, target):
3+
"""
4+
:type nums: List[int]
5+
:type target: int
6+
:rtype: List[int]
7+
"""
8+
dict = {}
9+
10+
for i , num in enumerate(nums):
11+
if target - num in dict:
12+
return (i, dict[target- num])
13+
else:
14+
dict[num] = i

checklist.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
What's the motivation behind the problem?
2+
How could you use it to solve real-world problems?
3+
What are the insights, the clever observations made on the problem's constraints that make the solution possible?
4+
What details of the problem does the solution take advantage of to get that extra performance gain / space saving?
5+
Where does the algorithm / data-structure / solution suck?
6+
How could you make it better?
7+
What do you lose and gain by doing so?
8+
For the specific problem at hand, which solution presents the most acceptable trade-offs?

0 commit comments

Comments
 (0)