Leetcode 399 Python Example Code