diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2024-08-25 01:01:55 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2024-08-25 01:01:55 +0900 |
| commit | 6666388bbfc5f66756464151ff894a76a25c4ebb (patch) | |
| tree | e9b85c5dbbf0efa00780d8c3df8ee2752bc8cfa5 /1_array_hashing/two_sum.py | |
| parent | b6855458c3c74ee93496275ea97bc3ba97a31e07 (diff) | |
Init
Diffstat (limited to '1_array_hashing/two_sum.py')
| -rw-r--r-- | 1_array_hashing/two_sum.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/1_array_hashing/two_sum.py b/1_array_hashing/two_sum.py index 76ea68d..534ec87 100644 --- a/1_array_hashing/two_sum.py +++ b/1_array_hashing/two_sum.py @@ -37,7 +37,6 @@ Constraints: -10,000,000 <= target <= 10,000,000 """ - from typing import List @@ -70,7 +69,12 @@ Solution url: https://neetcode.io/problems/two-integer-sum video: https://youtu.be/KLlXCFG5TnA -code: + +1. hashmap +time: +space: +code: +```python class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: prevMap = {} # val -> index @@ -80,4 +84,5 @@ class Solution: if diff in prevMap: return [prevMap[diff], i] prevMap[n] = i +``` """ |
