Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use hashset to store all elements.
Loop again to count all valid elements.
Solve with full IDE support and test cases