Given an array of size N in which every number is between 1
and N, determine if there are any duplicates in it. You are
allowed to destroy the array if you like.

Answers were Sorted based on User's Feedback



Given an array of size N in which every number is between 1 and N, determine if there are any dupli..

Answer / purnank

Get the summation. If it is not equal to (2N + 1)/2, you
surely have duplicates.

Is This Answer Correct ?    11 Yes 46 No

Post New Answer

More C Code Interview Questions

#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }

1 Answers   TCS,


write a c program to Create employee record by taking details like name, employee id, address and phone number. While taking the phone number, take either landline or mobile number. Ensure that the phone numbers of the employee are unique. Also display all the details

2 Answers   TCS,


main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }

3 Answers  


#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }

3 Answers  


enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }

2 Answers  


What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql

0 Answers  


main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }

4 Answers   CSC,


write a c program to print magic square of order n when n>3 and n is odd?

1 Answers   HCL,


main() { extern int i; i=20; printf("%d",sizeof(i)); }

2 Answers  


Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };

1 Answers  


#include<stdio.h> int main() { int a=3,post,pre; post= a++ * a++ * a++; a=3; pre= ++a * ++a * ++a; printf("post=%d pre=%d",post,pre); return 0; }

3 Answers  


Printf can be implemented by using __________ list.

3 Answers  


Categories