Find the largest Alphabetic character present in the string | Function to find the Largest Alphabetic Character ; Array for keeping track of both uppercase and lowercase english alphabets ; Iterate from right side of array to get the largest index character ; Check for the character if both its uppercase and lowercase exist or not ; Return - 1 if no such character whose uppercase and lowercase present in string str ; Driver code
def largestCharacter ( str ) : NEW_LINE INDENT uppercase = [ False ] * 26 NEW_LINE lowercase = [ False ] * 26 NEW_LINE arr = list ( str ) NEW_LINE for c in arr : NEW_LINE INDENT if ( c . islower ( ) ) : NEW_LINE INDENT lowercase [ ord ( c ) - ord ( ' a ' ) ] = True NEW_LINE DEDENT if ( c . isupper ( ) ) : NEW_LINE INDENT uppercase [ ord ( c ) - ord ( ' A ' ) ] = True NEW_LINE DEDENT DEDENT for i in range ( 25 , - 1 , - 1 ) : NEW_LINE INDENT if ( uppercase [ i ] and lowercase [ i ] ) : NEW_LINE INDENT return chr ( i + ord ( ' A ' ) ) + " " NEW_LINE DEDENT DEDENT return " - 1" NEW_LINE DEDENT str = " admeDCAB " NEW_LINE print ( largestCharacter ( str ) ) NEW_LINE