0
/ 10
The code below counts the number of elements that appear in duplicate in an array. Which of the folowing statements are true?
static int...
The code below counts the number of elements that appear in duplicate in an array. Which of the folowing statements are true?
static int duplicates(int[] nums)
{
int dups = 0;
for (int i = 0; i < nums.length; i++) {
for (int j = 0; j < nums.length; j++) {
if (i != j) // we ignore it
if (nums[i] == nums[j])
dups++;
}
}
return dups;
}
Your feedback will appear here when you check your answer.