I have seen this and this. I was wondering if I could do it without using libraries like collection, but with a simple loop structure. Can I do this in Python?
void printRepeating(int arr[], int size)
{
int *count = (int *)calloc(sizeof(int), (size - 2));
int i;
printf(" Repeating elements are ");
for(i = 0; i < size; i++)
{
if(count[arr[i]] == 1)
printf(" %d ", arr[i]);
else
count[arr[i]]++;
}
}
I tried doing this -
a=[1,2,3,2,4,3,1,7,4,3];
b=[];
for i in a:
b[i]=b[i]+1;
But I get
IndexError: list index out of range
Is there a way around it?