It is better to write the if statement as "if(a[in - 1] == temp && a[in - 1] != -1) " otherwise, it could cause an incorrect result for nCopies.
It is better to write the if statement as "if(a[in - 1] == temp && a[in - 1] != -1) "
otherwise, it could cause an incorrect result for nCopies.