Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use the set to count the number of distinct elements on diagonals.
Solve with full IDE support and test cases