Iterate over all possible pairs
for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT if ( checkValidPair ( arr [ i ] , arr [ j ] ) ) : NEW_LINE INDENT numberOfPairs += 1 NEW_LINE DEDENT DEDENT DEDENT return numberOfPairs NEW_LINE