File tree 3 files changed +26
-3
lines changed
3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 40
40
41
41
42
42
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 |
46
47
47
48
48
49
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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?
You can’t perform that action at this time.
0 commit comments