simple one!! ..... all the missing nos which r not present b/w 1 to n will be printed!! TC O(n)
#include <stdio.h> #define size 10000 int main() { int i, j, n; scanf("%d", &n); int a[n + 1] ; int b[n + 1] ; a[0] = 0; b[0] = 0; for (i = 1; i <= n ; i++){ scanf("%d", &a[i]); b[i] = 0; } for(j = 1; j <= n ; j++){ if (b[a[j]] == 0){ b[a[j]] = 1; } } printf("missing no's are: \n"); for( i = 1; i <= n ; i++){ // printf("%d ",b[i] ); if(b[i] == 0){ printf("%d ", i); } } return 0; } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.