cybersecurity · intermediate · ~15 min · safe pentest lab

Distinct ports touched

Count unique values.

Challenge

Implement int distinct_ports(const int *ports, int n) returning the number of distinct port numbers in the array.

Starter code

int distinct_ports(const int *ports, int n) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.