Problem
Say that we have strings and with . Consider the substring . We have two cases:
- If , then we set because is shorter than (e.g., ).
- Otherwise, . We define if and define if (e.g., because ).
Given: A permutation of at most 12 symbols defining an ordered alphabet and a positive integer ().
Return: All strings of length at most formed from , ordered lexicographically. (Note: As in “Enumerating k-mers Lexicographically”, alphabet order is based on the order in which the symbols are given.)
说我们有琴弦 和 与 。考虑子串。我们有两种情况:
- 如果 ,然后我们设置 因为 短于 (例如, )。
- 除此以外, 。我们定义 如果 并定义 如果 (例如, 因为 )。
给定:最多12个符号的排列,定义一个有序字母 和一个正整数 ()。
返回:最多所有长度的字符串 由...组成 ,按字典顺序排序。(注意:与“按字典顺序枚举k-mers”中一样,字母顺序基于给出符号的顺序。)
Sample Dataset
D N A
3
Sample Output
D
DD
DDD
DDN
DDA
DN
DND
DNN
DNA
DA
DAD
DAN
DAA
N
ND
NDD
NDN
NDA
NN
NND
NNN
NNA
NA
NAD
NAN
NAA
A
AD
ADD
ADN
ADA
AN
AND
ANN
ANA
AA
AAD
AAN
AAA