Leetcode 856 Python Recursion