I need to compare the guess and code arrays and count the number of correct digits in the guess.

It works until there are duplicate numbers in the code array. I know it's something to do with the second for loop and subtracting from the correctDigits.

```java
public static int digits(int[] code, int[] guess) {
    int digits = 0;

    for (int i = 0; i < code.length; i++) {
        for (int j = 0; j < guess.length; j++) {
            if (guess[j] == code[i]) {
                digits++;
                break;
            }
        }
    }

    for (int i = 0; i < code.length; i++) {
        for (int j = i + 1; j < code.length; j++) {
            if (code[i] == code[j] && code[i] != guess[j] && code[j] != guess[i]) {
                digits--;
            }
        }
    }

    return digits;
}

```