text: Number of subsets whose mean is maximum | C # implementation of the approach ; Function to return the count of subsets with the maximum mean ; Maximum value from the array ; To store the number of times maximum element appears in the array ; Return the count of valid subsets ; Driver code
code: using System ; using System . Linq ; class GFG { static int cntSubSets ( int [ ] arr , int n ) { int maxVal = arr . Max ( ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == maxVal ) cnt ++ ; } return ( int ) ( Math . Pow ( 2 , cnt ) - 1 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 , 2 } ; int n = arr . Length ; Console . WriteLine ( cntSubSets ( arr , n ) ) ; } }