You have a lock with 4 circular wheels, each showing the digits 0 to 9. The wheels wrap around: 9 turns to 0 and 0 turns to 9, and one move turns one wheel by one slot. The lock starts at "0000". You are given a list of deadends: if the lock ever shows one of them, the wheels jam. Given a target, return the minimum number of moves needed to open the lock, or -1 if it is impossible.
You have a lock with 4 circular wheels, each showing the digits 0 to 9. The wheels wrap around: 9 turns to 0 and 0 turns to 9, and one move turns one wheel by one slot. The lock starts at "0000". You are given a list of deadends: if the lock ever shows one of them, the wheels jam. Given a target, return the minimum number of moves needed to open the lock, or -1 if it is impossible.