Skip to content

Commit 51c7621

Browse files
committed
Adding readme file
1 parent 1b2492a commit 51c7621

File tree

1 file changed

+42
-0
lines changed
  • 1415-Thek-thLexicographicalStringofAllHappyStringsofLengthn

1 file changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
A happy string is a string that:
2+
3+
4+
consists only of letters of the set ['a', 'b', 'c'].
5+
s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).
6+
7+
8+
For example, strings "abc", "ac", "b" and "abcbabcbcb" are all happy strings and strings "aa", "baa" and "ababbc" are not happy strings.
9+
10+
Given two integers n and k, consider a list of all happy strings of length n sorted in lexicographical order.
11+
12+
Return the kth string of this list or return an empty string if there are less than k happy strings of length n.
13+
14+
 
15+
Example 1:
16+
17+
Input: n = 1, k = 3
18+
Output: "c"
19+
Explanation: The list ["a", "b", "c"] contains all happy strings of length 1. The third string is "c".
20+
21+
22+
Example 2:
23+
24+
Input: n = 1, k = 4
25+
Output: ""
26+
Explanation: There are only 3 happy strings of length 1.
27+
28+
29+
Example 3:
30+
31+
Input: n = 3, k = 9
32+
Output: "cab"
33+
Explanation: There are 12 different happy string of length 3 ["aba", "abc", "aca", "acb", "bab", "bac", "bca", "bcb", "cab", "cac", "cba", "cbc"]. You will find the 9th string = "cab"
34+
35+
36+
 
37+
Constraints:
38+
39+
40+
1 <= n <= 10
41+
1 <= k <= 100
42+

0 commit comments

Comments
 (0)