Leetcode Maximum Recursion Depth Exceeded While Pickling Cucumbers