Leetcode 399 Python Recursive Problems