For quest 1 given as "Each number is present at least once except for 2 numbers." We can't apply the math formula unless its given as exactly once ?
On Wed, Jul 20, 2011 at 4:28 PM, saurabh singh <saurab...@gmail.com> wrote: > space o(n) too....mine takes o(1) space > > > On Wed, Jul 20, 2011 at 3:50 PM, JIƬΣN BAJIYA <j.s.baj...@gmail.com>wrote: > >> 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. >> > > > > -- > Saurabh Singh > B.Tech (Computer Science) > MNNIT ALLAHABAD > > > -- > 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. > -- Cheers, Vicky -- 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.