Sponsored
Use these hints if you're stuck. Try solving on your own first.
For every possible pair of indices (i, j) where i < j, check if it satisfies the given conditions.
Solve with full IDE support and test cases