From 6666388bbfc5f66756464151ff894a76a25c4ebb Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Sun, 25 Aug 2024 01:01:55 +0900 Subject: Init --- 1_array_hashing/two_sum.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to '1_array_hashing/two_sum.py') 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 +``` """ -- cgit v1.2.3