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 , ; Update maximum count if lowercase character before this is more . ; clear the set ; If character is in lowercase ; Driver Code
using System ; using System . Collections . Generic ; class GFG { static int maxLower ( char [ ] str ) { int n = str . Length ; int i = 0 ; for ( ; i < n ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { i ++ ; break ; } } int maxCount = 0 ; HashSet < int > s = new HashSet < int > ( ) ; for ( ; i < n ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { maxCount = Math . Max ( maxCount , ( int ) s . Count ) ; s . Clear ( ) ; } if ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) s . Add ( ( int ) str [ i ] ) ; } return maxCount ; } public static void Main ( String [ ] args ) { String str = " zACaAbbaazzC " ; Console . WriteLine ( maxLower ( str . ToCharArray ( ) ) ) ; } }