Graph Theory37 sections · 1633 units
Open in Course

Problem - Cracking the Safe

LeetCode 753 - De Bruijn application.

Problem: A safe has a password of nn digits where each digit is 00 to k1k-1. Find the shortest string that contains all possible passwords as substrings.

Link: LeetCode 753

Example: n=2n = 2, k=2k = 2. Passwords: 00,01,10,1100, 01, 10, 11. Answer: "0110001100" (length 55).

Connection: This is the De Bruijn sequence problem generalized to alphabet size kk. Build a De Bruijn graph and find an Euler circuit.