Python Leetcode Producing Inconsistent Runtime Stack Overflow

Python Leetcode Producing Inconsistent Runtime Stack Overflow