Practice Lexicographically Smallest Beautiful String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A beautiful string uses only the first k lowercase letters and contains no palindromic contiguous substring of length at least two. Given a beautiful s, return the lexicographically smallest beautiful string of the same length strictly greater than s, or an empty string if none exists.
Source: Lexicographically Smallest Beautiful String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "abcz", k = 26
Output
"abda"
# Example 2
Input
s = "dc", k = 4
Output
""
Constraints
1 <= n == s.length <= 10^5
4 <= k <= 26
s is a beautiful string.
Related LeetCode Problems
Practice more problems similar to Lexicographically Smallest Beautiful String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.