CT065

De Bruijn Sequence

HardAcceptance: 0.0%

For a set of characters C and an integer k, a De Bruijn sequence is a cyclic sequence in which every possible k-length string of characters in C occurs exactly once. Given C (as a string of characters) and k, find a De Bruijn sequence. Input: first line C, second line k. Output: the De Bruijn sequence.

Example 1:

Input: 01 3
Output: 00010111

Example 2:

Input: ab 2
Output: aabb

Constraints:

1 <= len(C) <= 10 1 <= k <= 6 C contains distinct characters

Tags:

graph eulerian-cycle hierholzer
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki