Leetcode 856 Python Explanation