Given an array of length N containing integers between 1
and N, determine if it contains any duplicates.

Answer Posted / sid

duplicate = False;
for (i =1; i <= N; i++)
{
a[a[i] % N] += N;
}

for (i =1; i <= N; i++)
{
if (a[i] / N >= 2)
{
duplicate = True;
}
}
return duplicate;

Is This Answer Correct ?    14 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

plz let me know how to become a telecom protocol tester. thank you.

1743


What is the explanation for the dangling pointer in c?

683


how can i access hard disk address(physical address)? are we access hard disk by using far,near or huge pointer? if yes then please explain.....

1373


Explain how are 16- and 32-bit numbers stored?

786


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

1919






Explain what is the heap?

624


how to capitalise first letter of each word in a given string?

1434


pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)

1863


What does %p mean c?

633


Explain how can type-insensitive macros be created?

572


What is the use of the function in c?

599


Is a house a shell structure?

697


What is the data segment that is followed by c?

616


How old is c programming language?

581


Is it possible to use curly brackets ({}) to enclose single line code in c program?

800