Model this as a graph problem. Each lock combination is a node. Two nodes are connected if they differ by one wheel turn.
Use BFS starting from "0000". Deadends are nodes you cannot visit. First time you reach the target, return the number of steps.
Use a visited set to avoid revisiting states. Add deadends to visited before starting.