2663. Lexicographically Smallest Beautiful String
A string is beautiful if:
- It consists of the first
k
letters of the English lowercase alphabet.- It does not contain any substring of length
2
or more which is a palindrome.You are given a beautiful string
s
of lengthn
and a positive integerk
.Return the lexicographically smallest string of length
n
, which is larger thans
and is beautiful. If there is no such string, return an empty string.A string
a
is lexicographically larger than a stringb
(of the same length) if in the first position wherea
andb
differ,a
has a character strictly larger than the corresponding character inb
.
- For example,
"abcd"
is lexicographically larger than"abcc"
because the first position they differ is at the fourth character, andd
is greater thanc
.
c++
1 |
|