Leetcode Question On Recursion In Python