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
Which is better pointer or array?
What is break statement?
ATM machine and railway reservation class/object diagram
What is a loop?
What is an lvalue in c?
What is mean by data types in c?
What are the benefits of c language?
Can we declare function inside main?
Describe explain how arrays can be passed to a user defined function
What is the difference between null pointer and wild pointer?
Explain what is dynamic data structure?
write a program to rearrange the array such way that all even elements should come first and next come odd
Write a program to find the biggest number of three numbers in c?
Why isnt there a numbered, multi-level break statement to break out
Explain what is gets() function?