Leetcode Maximum Recursion Depth Exceeded While Calling