Maximum distinct lowercase alphabets between two uppercase | 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
def maxLower ( str ) : NEW_LINE INDENT n = len ( str ) ; NEW_LINE i = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( str [ i ] >= ' A ' and str [ i ] <= ' Z ' ) : NEW_LINE INDENT i += 1 ; NEW_LINE break ; NEW_LINE DEDENT DEDENT maxCount = 3 ; NEW_LINE s = set ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( str [ i ] >= ' A ' and str [ i ] <= ' Z ' ) : NEW_LINE INDENT maxCount = max ( maxCount , len ( s ) ) ; NEW_LINE s . clear ( ) ; NEW_LINE DEDENT if ( str [ i ] >= ' a ' and str [ i ] <= ' z ' ) : NEW_LINE INDENT s . add ( str [ i ] ) ; NEW_LINE return maxCount ; NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str = " zACaAbbaazzC " ; NEW_LINE print ( maxLower ( str ) ) ; NEW_LINE DEDENT