Leetcode 856 Python Solution Block