The Cracking the Safe interview question is a mathematical puzzle involving combinations. You have a safe with an -digit password, where each digit can be from to . The safe opens if the last digits entered match the password. You want to find the shortest possible string that contains all possible passwords as substrings.
Google uses the Cracking the Safe coding problem to evaluate a candidate's knowledge of advanced graph theory, specifically De Bruijn sequences and Eulerian Circuits. It’s a "Hard" problem because it requires modeling passwords as edges in a directed graph and finding a path that visits every edge exactly once.
This problem uses the Hierholzer’s Algorithm to find an Eulerian Circuit.
(Passwords: 00, 01, 10, 11)
This is a niche but classic problem. If you encounter it, mention "De Bruijn Sequences." Even if you don't remember the exact algorithm, identifying the graph theory category shows high-level expertise.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Reconstruct Itinerary | Hard | Solve | |
| Valid Arrangement of Pairs | Hard | Solve | |
| Maximize Amount After Two Days of Conversions | Medium | Solve | |
| Find Closest Node to Given Two Nodes | Medium | Solve | |
| Longest Path With Different Adjacent Characters | Hard | Solve |