Well if I use this for example:-
for(i=0 ;i<n ;i++)
{
for(j=0;j<n;j++)
{
if(array[i] != array[j])
return 0;
}
}
in this case the time complexity is O(n^2) but how can I check duplicates in an easier and shorter way in order to make the time complexity O(n)? also what does a space complexity of O(k) while k is constant and k is smaller then the inputs size? (k is smaller than n).Thx for any suggestions