Find the largest Alphabetic character present in the string | C # program to Find the Largest Alphabetic char present in the string of both uppercase and lowercase English characters ; Function to find the Largest Alphabetic char ; 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
using System ; class GFG { public static String largestchar ( String str ) { bool [ ] uppercase = new bool [ 26 ] ; bool [ ] lowercase = new bool [ 26 ] ; char [ ] arr = str . ToCharArray ( ) ; foreach ( char c in arr ) { if ( char . IsLower ( c ) ) lowercase = true ; if ( char . IsUpper ( c ) ) uppercase = true ; } for ( int i = 25 ; i >= 0 ; i -- ) { if ( uppercase [ i ] && lowercase [ i ] ) return ( char ) ( i + ' A ' ) + " " ; } return " - 1" ; } public static void Main ( String [ ] args ) { String str = " admeDCAB " ; Console . WriteLine ( largestchar ( str ) ) ; } }