Tap here to switch tabs
Problem
Submissions

Problem: K-th Lexicographical Happy String of Length n

Try to solve the The k-th Lexicographical String of All Happy Strings of Length n problem.

Statement

A happy string is defined as a string that:

  • Consists only of characters from the set ['a', 'b', 'c'].

  • Does not contain any two adjacent characters that are equal (that is, s[i] != s[i + 1] for all valid indices i).

Given two integers n and k, consider all happy strings of length n sorted in lexicographical order.

Return the kextthk^{ ext{th}} happy string of length n from this sorted list. If there are fewer than k happy strings of length n, return an empty string "".

Constraints:

  • 1≤1 \leq n ≤10\leq 10

  • 1≤1 \leq k ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: K-th Lexicographical Happy String of Length n

Try to solve the The k-th Lexicographical String of All Happy Strings of Length n problem.

Statement

A happy string is defined as a string that:

  • Consists only of characters from the set ['a', 'b', 'c'].

  • Does not contain any two adjacent characters that are equal (that is, s[i] != s[i + 1] for all valid indices i).

Given two integers n and k, consider all happy strings of length n sorted in lexicographical order.

Return the kextthk^{ ext{th}} happy string of length n from this sorted list. If there are fewer than k happy strings of length n, return an empty string "".

Constraints:

  • 1≤1 \leq n ≤10\leq 10

  • 1≤1 \leq k ≤100\leq 100