X916: Big O - 5

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 Answer:

Select one answer:


Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.