text: Frequency Measuring Techniques for Competitive Programming | C # program to count frequencies of array items ; Create an array to store counts . The size of array is limit + 1 and all values are initially 0 ; Traverse through string characters and count frequencies ; Driver Code
code: using System ; class GFG { static int limit = 25 ; static void countFreq ( String str ) { int [ ] count = new int [ limit + 1 ] ; for ( int i = 0 ; i < str . Length ; i ++ ) count [ str [ i ] - ' A ' ] ++ ; for ( int i = 0 ; i <= limit ; i ++ ) if ( count [ i ] > 0 ) Console . WriteLine ( ( char ) ( i + ' A ' ) + " ▁ " + count [ i ] ) ; } public static void Main ( String [ ] args ) { String str = " GEEKSFORGEEKS " ; countFreq ( str ) ; } }