I'm new to calculating time complexity. I've searched around and I understand the very basics of it. I have the following algorithm, I'm trying to calculate the complexity of for practice. Am I correct it would be O(n)?
Also, are there any recommendations on places to practice this concept?
class Solution:
def twoSum(self, nums, target):
h = {}
for i, num in enumerate(nums):
n = target - num
if n not in h:
h[num] = i
else:
return [h[n],i]
Answer = Solution()
print (Answer.twoSum([2,3,4], 7))