String Minimal Representation¶
Table of Contents¶
- 1163. Last Substring in Lexicographical Order (Hard)
- 899. Orderly Queue (Hard)
- 3403. Find the Lexicographically Largest String From the Box I (Medium)
1163. Last Substring in Lexicographical Order¶
-
LeetCode | LeetCode CH (Hard)
-
Tags: two pointers, string
899. Orderly Queue¶
-
LeetCode | LeetCode CH (Hard)
-
Tags: math, string, sorting
3403. Find the Lexicographically Largest String From the Box I¶
-
LeetCode | LeetCode CH (Medium)
-
Tags: two pointers, string, enumeration
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"