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
What is 1f in c?
Write a program of prime number using recursion.
What is difference between structure and union?
What is wrong with this declaration?
Is it possible to execute code even after the program exits the main() function?
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
What is "Hungarian Notation"?
Find MAXIMUM of three distinct integers using a single C statement
What is the importance of c in your views?
Why do we use static in c?
What is the meaning of && in c?
Is null a keyword in c?
What is the difference between the = symbol and == symbol?
What is #define used for in c?
What are variables and it what way is it different from constants?