Well, i see what you are trying to do but you are toying around with uninitialized values.
Lets see, you declared id[10000000] but didn’t initialize its elements with ‘0’ so they contain some unwanted value (!=0) so performing increment operation ‘id[temp]=id[temp]+1’ will not give desired result, same with the variable ‘max’, you didn’t initialize it to ‘0’
You can either use memset on ‘id[10000000]’ or use ‘map’
no, uninitialized variable are not zero they contain some value(!=0)(check it out yourself, declare a variable and print it, you will realize), you need to initialize it. memset is used to easily initialize an array, like to initialize ‘id’-> “memset(id,0,10000000)” or you can run a loop from 10000000 times and equate each element to ‘0’