LeetCode 752. Open the Lock
Given a 4-digit combination lock starting at '0000', find the minimum number of single-digit rotations needed to reach a target combination while avoiding forbidden deadend combinations. Each digit (0–9) wraps around (9→0 and 0→9). Return -1 if the target is unreachable. This is a shortest-path problem in an implicit graph of 10^4 states with forbidden nodes, best solved using BFS or bidirectional BFS.
Asked at:
B
Brex
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Early March, 2026
B
Brex
Senior
Mid September, 2025
Meta
Senior
Late April, 2025
Meta
Mid-level
Hello Interview Premium
Your account is free and you can post anonymously if you choose.