The k-th Lexicographical String of All Happy Strings of Length n
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 ofifrom1tos.length - 1(string is 1-indexed).
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
Input
n = 1, k = 3Output
"c"The list ["a", "b", "c"] contains all happy strings of length 1, and the third string is "c".
Example 2
Input
n = 1, k = 4Output
""There are only 3 happy strings of length 1.
Constraints
- 1 <= n <= 10
- 1 <= k <= 100