July 07, 2022 |1.8K Views

    Smallest alphabet greater than a given character

      Share   Like
    Description
    Discussion

    Given a list of sorted characters consisting of both Uppercase and Lowercase Alphabets and a particular target value, say K, the task is to find the smallest element in the list that is larger than K. 
    Letters also wrap around. For example, if K = ‘z’ and letters = [‘A’, ‘r’, ‘z’], then the answer would be ‘A’.

    Input : Letters = ["D", "J", "K"]
           K = "B"
    Output: 'D'
    Explanation:
    The Next greater character of "B" is 'D'
    since it is the smallest element from the 
    set of given letters, greater than "B".

    smallest alphabet greater than a given character  : https://www.geeksforgeeks.org/smallest-alphabet-greater-than-a-given-character/