Back to course home
0% completed
Vote For New Content
Using Two Pointers Approach Instead of Hashmap
amazonintern101
Aug 14, 2023
class Solution: def numGoodPairs(self, nums): pairCount = 0 # TODO: Write your code here left, right = 0,0 while left < len(nums) - 1: right += 1 if nums[left] == nums[right] and left < right: pairCount += 1 if right == len(nums) - 1: left += 1 right = left return pairCount
0
0
Comments
Comments
K
kurtanthony.w 2 years ago
What is the time complexity for this algorithm?
Bodyul Andrei7 months ago
Compute comlexity n2