LC0217 - Contains Duplicate (EASY)#
This is the solution for Leetcode Problem 217 - Contains Duplicate.
1"""Solution to Leetcode 217 - 217
2
3Link : https://leetcode.com/problems/contains-duplicate/
4Level: easy
5"""
6from typing import List
7
8
9class Solution:
10 def __init__(self, *args, **kwargs):
11 """Instantiates the solution object"""
12 self.args = args
13 self.kwargs = kwargs
14
15 def containsDuplicate(self, nums: List[int]) -> bool:
16 items = {}
17 for item in nums:
18 if items.get(item) is not None:
19 return True
20 else:
21 items[item] = 1
22 return False
23
24 def solve(self, *args, **kwargs):
25 """This implements the main solution"""
26 return self.containsDuplicate(args[0])