一个字符串如果只包含元音字母'a' 、'e'、 'i' 、'o' 、'u',且‘e’最多连续出现两次,其他字符不能连续出现,则称其为和谐字符串。现在给你两个整数n和k,将所有长度为n的和谐字符串按字典序从小到大排列,请你求出排在第k位的和谐字符串,若不存在则返回空字符串。(字典序:按字母顺序排列)
输入示例
3 4
2 2
2 1000
3 567
4 80
输出示例
aeo
ai
eaiu
- 字符串长度为 n
len(s) = n - 只包含'a' 、'e'、 'i' 、'o' 、'u'
s.count('a') + s.count('e') + s.count('i') + s.count('o') + s.count('u') == n - 字符串长度为 n 且 为和谐字符串
s.count("aa") = 0 and s.count("ii") = 0 and s.count("oo") = 0 and s.count("uu") = 0 and
s.count("eee") = 0 - 将所有和谐字符串加入list,然后 list.sort()
- 输出list[k-1]