diff --git a/1-100q/TwoSum.py b/1-100q/TwoSum.py index fb6e77b..8a73c4d 100644 --- a/1-100q/TwoSum.py +++ b/1-100q/TwoSum.py @@ -21,6 +21,25 @@ def twoSum(self, nums, target): return [index, mapping[diff]] else: mapping[val] = index +#Solution with the help of pointer +class Solution(object): + def twoSum(self,nums,target): + left=0 + right=len(nums)-1 #sorted array so largest and smallest numbers + while lefttarget: + right-=1 + else: + left+=1 + return False + + + + + # Space: O(N) # Time: O(N)