DSA Key Problems

Open the Lock

Given forbidden states and a target for a four-wheel decimal lock, return the fewest single-wheel turns needed to reach the target from 0000, with digits wrapping between 0 and 9, or -1 if it is unreachable.