Codility PermCheck why my solution is not working
The reason this isn't working is that a permutation (as explained) is not the only way to arrive at a particular sum, as your solution assumes. For example:
[0, 1, 2, 3] // Sum == 6
[0, 2, 2, 2] // Sum == 6
According to the problem description as written, I don't believe it implies the given data has no duplicates.
If N is 100,000, then the N * (N + 1) / 2 expression causes integer overflow(eventhough sum is a long, N is an int). Not sure if there are other bugs.
Code: 08:25:58 UTC, c, final, score: 100.00
int solution(int A[], int N) {
// write your code in C99
int T[N];
//when the compiler sees N variable declaration it cannot know how many
//elements there are in the array.
//must manually initialize that array.
memset( T, 0, N*sizeof(int) );
for (int i=0;i<N;i++)
{
if (A[i]>N)
{
return 0;
}
T[A[i]-1]++;
}
int sum=0;
for (int i=0;i<N;i++)
{
sum =sum+T[A[i]-1];
}
return (sum==N)?1:0;
}