Given a sorted array of integers and in the same array,shuffle the integers to have unique elements & fill the remaining spaces of the array with value '0'
#include <stdio.h> #include <stdlib.h> #define MAX 1000000 int main(void) { int n,i,*a,hash[MAX],x,j=0,index; scanf("%d",&n); memset(hash,0,sizeof(hash)); a=(int*)malloc(sizeof(int)*n); for(i=0;i<n;i++) { scanf("%d",&x); if(hash[x]==0) { a[j++]=x; } hash[x]=1; } index=j-1; for(;j<n;j++) *(a+j)=0; for(i=0;i<n;i++) printf("%d ",*(a+i)); printf("\n%d",index); return 0; }