1415. The k-th Lexicographical String of All Happy Strings of Length n
https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n
Description
A happy string is a string that:
consists only of letters of the set
['a', 'b', 'c']
.s[i] != s[i + 1]
for all values ofi
from1
tos.length - 1
(string is 1-indexed).
For example, strings "abc", "ac", "b" and "abcbabcbcb" are all happy strings and strings "aa", "baa" and "ababbc" are not happy strings.
Given two integers n
and k
, consider a list of all happy strings of length n
sorted in lexicographical order.
Return the kth string of this list or return an empty string if there are less than k
happy strings of length n
.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= n <= 10
1 <= k <= 100
ac
Previous1414. Find the Minimum Number of Fibonacci Numbers Whose Sum Is KNext1416. Restore The Array
Last updated