int heightChecker(int* heights, int heightsSize){ int hash[101]={0}; int i,j,count=0; for (i=0; i<heightsSize; i++) hash[heights[i]]++; for (i=0,j=1; i<heightsSize; j++) while(hash[j]-- > 0) if (heights[i++] != j) count++; return count; }
int heightChecker(int* heights, int heightsSize){ int hash[101]={0}; int i,j,count=0; for (i=0; i<heightsSize; i++) hash[heights[i]]++; for (i=0,j=1; i<heightsSize; j++) while(hash[j]-- > 0) if (heights[i++] != j) count++; return count; }