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
function largestCharacter ( str ) { let uppercase = new Array ( 26 ) ; uppercase . fill ( false ) ; let lowercase = new Array ( 26 ) ; lowercase . fill ( false ) ; let arr = str . split ( ' ' ) ; for ( let c = 0 ; c < arr . length ; c ++ ) { if ( arr == arr . toLowerCase ( ) ) lowercase [ arr . charCodeAt ( ) - 97 ] = true ; if ( arr == arr . toUpperCase ( ) ) uppercase [ arr . charCodeAt ( ) - 65 ] = true ; } for ( let i = 25 ; i >= 0 ; i -- ) { if ( uppercase [ i ] && lowercase [ i ] ) return String . fromCharCode ( i + ' ' . charCodeAt ( ) ) + " " ; } return " " ; } let str = " " ; document . write ( largestCharacter ( str ) ) ;