Skip to content

String Minimal Representation

Table of Contents

1163. Last Substring in Lexicographical Order

899. Orderly Queue

3403. Find the Lexicographically Largest String From the Box I

3403. Find the Lexicographically Largest String From the Box I - Python Solution
# Lexicographically Smallest/Largest
def answerString(word: str, numFriends: int) -> str:
    if numFriends == 1:
        return word

    n = len(word)
    return max(word[i : i + n - numFriends + 1] for i in range(n))


if __name__ == "__main__":
    assert answerString("dbca", 2) == "dbc"

Comments