MEDIUMasked at 10 companies

Open the Lock

A medium-tier problem at 61% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at CARS24 and 9 others.

Founder's read

Open the Lock is a medium-difficulty BFS problem that's hit interviews at eBay, Uber, ByteDance, Citadel, and J.P. Morgan. You're given a combination lock stuck on some starting code, a target code, and a list of codes you can't use. The naive greedy approach fails. Most candidates either code an inefficient DFS that times out or miss that this is a shortest-path problem disguised as a lock puzzle. About 61% pass it. If this problem lands in your live OA and you blank on the BFS setup, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
10
Difficulty
MEDIUM
Acceptance
61%

Companies that ask "Open the Lock"

If this hits your live OA

Open the Lock is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.

Get StealthCoder
What this means

The trick is recognizing this as a graph search: each lock state is a node, and each digit twist (up or down) is an edge. BFS finds the shortest sequence of moves. The gotcha is that candidates often try recursive backtracking or brute-force digit enumeration, which either explode in time complexity or get stuck in cycles. You need to track visited states in a hash table to avoid revisiting the same lock configuration. Start from the initial state, explore neighbors by turning each digit, skip blocked codes, and stop when you hit the target. It's a clean BFS with a set for visited states. This pattern shows up across Array, Hash Table, String, and Breadth-First Search topics. StealthCoder handles the state-space explosion and gives you the optimal path immediately.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Open the Lock recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Open the Lock interview FAQ

Is this really a medium, or does it feel harder?+

It's genuinely medium once you clock the BFS pattern, but it feels hard because the lock framing throws people off. Most candidates think simulation or greedy first, which fails. The 61% acceptance rate reflects that, it's not the algorithm, it's the mental model shift.

Will Uber or Citadel ask this exact problem?+

Not guaranteed, but both companies in this dataset have reportedly asked it. They like graph-search problems that test whether you spot the pattern fast. If it appears, you'll have maybe 30-45 minutes to code and test. BFS solution is about 20-30 lines once you nail the approach.

What's the most common mistake?+

Forgetting to track visited states, so you explore the same lock config over and over. Second mistake is not thinking of digit moves as '0' to '9' wrapping (0 minus 1 is 9, 9 plus 1 is 0). Both cause timeouts or wrong answers.

Does this require deep knowledge of Hash Table or BFS?+

No. You need to know BFS basics (queue, visited set) and a hash table or set for O(1) membership checks. If you're solid on standard graph traversal, you're fine. The lock state is just a string you check against a set.

How does this connect to the other topics?+

String handling is light (just lock codes as strings). Array and Hash Table support the BFS: you iterate through neighbors (array of possible digit moves) and store visited codes (hash table or set). BFS is the core algorithm; the others are implementation details.

Want the actual problem statement? View "Open the Lock" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.