Problem 1415 · Medium

The k-th Lexicographical String of All Happy Strings of Length n

Return the k-th string, in alphabetical order, of a fixed length built from a, b and c with no equal neighbouring letters. The visual shows the tree of valid prefixes and the branch taken at each position.

Open the interactive visualisation