Its a leethcode Question
https://leetcode.com/problems/find-the-duplicate-number/
Here they are saying :
You must not modify the array (assume the array is read only). You must use only constant, O(1) extra space. Your runtime complexity should be less than O(n^2). There is only one duplicate number in the array, but it could be repeated more than once.
So in my code i am creating a dictionary using Collection in python.
How my code is satisfying the this line "You must use only constant, O(1) extra space." and what do they mean by this line are they taking about Space complexity. Below is my code, which clears all testcase.
from collections import Counter
class Solution:
def findDuplicate(self, nums: List[int]) -> int:
dict1=Counter(nums)
for i in dict1:
if(dict1[i]>1):
return(i)
Please help. Thanks in advance.