Open the Lock - Leetcode 752 - Python