text: Count of distinct pair sum between two 1 to N value Arrays | C # implementation to count of distinct pair sum between two Array with values 1 to N ; Function to find the distinct sums ; Set to store distinct sums ; Inserting every sum ; Returning distinct sums ; Driver code
code: using System ; using System . Collections . Generic ; class GFG { static int findDistinctSums ( int n ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i ; j <= n ; j ++ ) { s . Add ( i + j ) ; } } return s . Count ; } public static void Main ( String [ ] args ) { int N = 3 ; Console . Write ( findDistinctSums ( N ) ) ; } }