Largest Alphabetic Character (Microsoft Interview)
Summary
During my Microsoft interview, I was presented with a string manipulation problem focused on identifying the largest alphabetic character that appears in both its uppercase and lowercase forms within a given string.
Full Experience
I recently had an interview with Microsoft where I encountered an interesting data structures and algorithms question. The problem statement was quite clear: given a string 'S', I needed to find the largest alphabetic character that has both its uppercase and lowercase versions present in the string. If such a character was found, its uppercase form should be returned; otherwise, I had to return '-1'. For example, if 'S' was 'scdbaBxC', the answer would be 'C' because both 'c' and 'C' exist, and 'C' is the largest such character. However, for 'abeCD', the answer would be '-1' since 'e' is present but its uppercase 'E' is not. This problem required careful thought about character sets and efficient searching.
Interview Questions (1)
Given a string S, find the largest alphabetic character, whose both uppercase and lowercase character appear in string str. The uppercase character should be returned. If there is no such character, return -1.
Examples:
Input: str = "scdbaBxC"
Output: C
Explanation: Both the uppercase and lowercase characters for letter C are present in the string, and it is also the largest alphabetical character, hence our output is C.
Input: str = "abeCD"
Output: -1
Explanation: Although the largest character is 'e' in the string, its uppercase version 'E' is not present, hence the output is -1.