Maximum distinct lowercase alphabets between two uppercase | C # Program to find maximum lowercase alphabets present between two uppercase alphabets ; Function which computes the maximum number of distinct lowercase alphabets between two uppercase alphabets ; Ignoring lowercase characters in the beginning . ; We start from next of first capital letter and traverse through remaining character . ; If character is in uppercase , ; Count all distinct lower case characters ; Update maximum count ; Reset count array ; If character is in lowercase ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int MAX_CHAR = 26 ; static int maxLower ( String str ) { int n = str . Length ; int i = 0 ; for ( ; i < n ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { i ++ ; break ; } } int maxCount = 0 ; int [ ] count = new int [ MAX_CHAR ] ; for ( ; i < n ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { int currCount = 0 ; for ( int j = 0 ; j < MAX_CHAR ; j ++ ) { if ( count [ j ] > 0 ) { currCount ++ ; } } maxCount = Math . Max ( maxCount , currCount ) ; Array . Fill ( count , 0 ) ; } if ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) { count [ str [ i ] - ' a ' ] ++ ; } } return maxCount ; } public static void Main ( String [ ] args ) { String str = " zACaAbbaazzC " ; Console . WriteLine ( maxLower ( str ) ) ; } }