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

What is getch () for?

683


Why c is called free form language?

577


What is an endless loop?

808


How are Structure passing and returning implemented by the complier?

719


What is binary tree in c?

630






Why is struct padding needed?

639


How are pointers declared in c?

603


i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me

1486


Tell me can the size of an array be declared at runtime?

603


c program for searching a student details among 10 student details

1662


State the difference between x3 and x[3].

657


Which programming language is best for getting job 2020?

613


What are types of preprocessor in c?

624


What are c identifiers?

631


Why isnt any of this standardized in c?

641