Largest Alphabetic Character (Microsoft Interview)

Posted
11 Jul 2022
301 reads

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.

How it went

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.

Questions asked (1)

  1. 01

    Largest Alphabetic Character

    Data Structures & Algorithms

    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.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Microsoft recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!